1

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.

Keyur Potdar
  • 7,158
  • 6
  • 25
  • 40
Adeel Abbas
  • 31
  • 1
  • 6

1 Answers1

0

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.

Void Ray
  • 9,849
  • 4
  • 33
  • 53
  • The problem is that "vanilla" Dapper ignores properties attributes like [Computed]... so being able to execute Stored Procedures with Dapper.Contrib would be quite useful in some circumstances. – Mahou5 Sep 30 '21 at 07:36