Let's say I have a user defined data type in the database:
MySuperType
which as two bigint properties in it (Id + Code)
And I have a stored procedure which takes in those parameters:
@MySuperType, @Price, @dateModified, etc...
Now in my code, I am using Dapper like this:
using (var connecion = new SqlConnection(_connectionString))
{
result = connection.Execute("SP_name",
new {mySuperType, price, date},
commandType: CommandType.StoredProcedure);
}
But I keep getting an error
Type Operand clash: Dapper is not able to map the user defined type: MySuperType from the parameters to the stored procedure.
Changing the stored procedure or replacing the user-defined type isn't an option
Does anyone have an idea what I can do to map the types and send the parameters (all of them) to the stored procedure?
Tha names of parameters must correspond to parameters defined in procedure:
using (var connecion = new SqlConnection(_connectionString))
{
result = connection.Execute("SP_name",
new {MySuperType = mySuperType, Price = price, dateModified = date},
commandType: CommandType.StoredProcedure);
}
Dapper is case sensitive in mapping in 2 directions (as parameters and as results).
If you want to avoid specifying names of the parameters, make sure you have it exactly same in variables in c# and stored procedure.