Returning values from stored procedure when using dapper.

Dapper doesn’ t read return values from stored proc, so this

 

CREATE PROC MyProc
AS
-- code....
return 1;

and then

int success = connection.Query<int>("MyProc", parameters, commandType: CommandType.StoredProcedure).First();

will fail, because nothing is actually returned.

As a fix, instead of returning value select it:
CREATE PROC MyProc
AS
-- code....
select 1;



Leave a Reply

Your email address will not be published. Required fields are marked *