I am trying to run a test to see if I loaded a
DynamicParameters object correctly. However, I cannot figure out what the Type is that I should use. I get exceptions when I try to use C#/.NET types (int, string, etc.). I tried to use SqlDbType, but that didn't work. I looked at source and I see that the value is stored as a
IDbDataParameter and then cast to the type. Obviously, the types I'm trying don't cast. The data I'm testing with are
int. How can I get the values?
var dbParams = new DynamicParameters(); dbParams.Add( "Field1", 1 ); var value = dbParams.Get<int>( "Field1" ); // throws an exception
The code only expected
Get<T> to be used after the SQL had been invoked, in order to obtain the updated value of
return parameters. Consequently it attempted to de-reference something that didn't exist yet. This will be fixed in the next release (it is fixed in the trunk now).