I'm working with Dapper and DB2. As far as I can see DB2 doesn't support GUID's natively, so I'm storing it as a string and using dappers access to private properties to help out.
class TestTable
{
public string RequestId
{
get { return RequestGuid.ToString(); }
private set { RequestGuid = new Guid(value); }
}
public Guid RequestGuid { get; set; }
}
I would rather RequestId was fully private, however if I do that the following fails
connection.Execute("INSERT INTO SOMETABLE (REQUESTID) VALUES(@REQUESTID)"
, new TestTable() { RequestGuid = Guid.NewGuid() });
The error is
Not enough parameters specified. The command requires 1 parameter(s), but only 0 parameter(s) exist in the parameter collection.
Should dapper be able to access a private getter?
Edit:
The connection.Execute works if I use the class as it is shown. I get the error if I make the RequestId private.