Execute stored procedure w/parameters in Dapper

前端 未结 5 886
被撕碎了的回忆
被撕碎了的回忆 2020-12-31 05:02

I\'m using Dapper (thanks Sam, great project.) a micro ORM with a DAL and by some reason I\'m not able to execute stored procedures with input parameters.

In a exam

5条回答
  •  情话喂你
    2020-12-31 05:31

    This works for me. Note that the method doing this is async, hence the await and QueryAsync. Also notice that an anonymous type is created to facilitate the 'Id' parameter being sent.

    await dbConnection.QueryAsync("StoredProcedureNameGoesHere @Id", new { Id = id });
    

提交回复
热议问题