I'm trying to create a generic base class for my DataObjects like this :
public abstract class BaseDataObject<TDOType> where TDOType : class
{
public static TDOType Get(Guid lObjectUUID, NpgsqlConnection conn)
{
return conn.Get<TDOType>(lObjectUUID);
}
public Guid Insert(NpgsqlConnection conn)
{
try
{
return conn.Insert<Guid, BaseDataObject<TDOType>>(this);
}
catch (Exception ex)
{
throw;
}
}
}
My inherited class :
[Table("mytable")]
public class MyTable : BaseDataObject<MyTable>
{
[Key]
[Column("mytableuuid")]
public Guid MyTableUUID { get; set; }
[Column("clientuuid")]
public Guid ClientUUID { get; set; }
}
When I call this method from an inherited object, I am thrown with the following message :
42601: syntax error at or near ")"
When I look at the statement in the exception that is being passed, it looks like this :
{insert into "mytable" () values ()}
Even when I cast 'this', as follows, the result is the same :
try
{
BaseDataObject<TDOType> q = this;
return conn.Insert<Guid, BaseDataObject<TDOType>>(q);
}
It would appear that the generic function is not properly seeing the members of my inherited class. What am I doing wrong?