How to run Procedures with Dapper

Posted on

Question :

How can I run a store procedure with Dapper?


Answer :

Assuming you wanted to get the result in a variable of type Cliente .

var cliente = connection.Query<Cliente>("spClientes", new {Id = 1}, 
                                    commandType: CommandType.StoredProcedure).First();

The first parameter is the name of the procedure, the second is the parameters passed to it, and the third is the type of command that will be executed.


Leave a Reply

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