Search code examples
dapperdapper-contrib

Store Procedures with Dapper.Contrib


I am newbie to Dapper and I Want to use Dapper.Contrib. Is there any method we can use store procedure with Dapper.Contrib methods.

e.g The method of Dapper.Contrib is connection.GetAll<Invoice>().ToList();. I want to call store procedure in this extension methods.


Solution

  • For stored procedures, use .Query<T> extension.

    var result = cnn.Query<Data>("spGetData", new {Id = 1}, 
            commandType: CommandType.StoredProcedure);
    

    Here is a Link to sql mapper extensions source code.