Executing stored procedures from a DbContext

前端 未结 1 1046
余生分开走
余生分开走 2021-02-15 15:14

I have two simple stored procedures in SqlServer:

  • SetData(@id int, @data varchar(10))
  • GetData(@id int).

Get

1条回答
  •  一向
    一向 (楼主)
    2021-02-15 15:47

    DbContext offers these functions. Use:

    IEumerable<...> result = myContext.Database.SqlQuery<...>(...)
    

    to execute retrieval stored procedure and

    int result = myContext.Database.ExecuteSqlCommand(...)
    

    to execute data modification stored procedure.

    0 讨论(0)
提交回复
热议问题