I am using Dapper
to call a stored procedure which have a mandatory parameter @idProject
this is my code fragment:
using (var c = _connectionWrapper.DbConnection)
{
var result = c.Query<Xxx>("dbo.xxx_xxxGetPage", new { @idProject = 1 }).AsList();
return result;
}
Should work but raise an exception:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: Procedure or function 'xxxGetPage' expects parameter '@idProject', which was not supplied.
Why?
I think you're missing the CommandType
.
using (var c = _connectionWrapper.DbConnection)
{
var result = c.Query<Xxx>("dbo.xxx_xxxGetPage", new { idProject = 1 }, commandType: CommandType.StoredProcedure).AsList();
return result;
}
By default, dapper uses Text.
https://github.com/StackExchange/dapper-dot-net
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With