must declare the scalar variable '@custid' using dbcontext.Database.SqlQuery?

前端 未结 2 341
你的背包
你的背包 2021-01-17 11:22

I am trying to execute stored procedure from bcontext.Database.SqlQuery using EF5.

It is throwing an error must declare the scalar variable \'@custid\'<

2条回答
  •  伪装坚强ぢ
    2021-01-17 11:58

    Since you're using named parameters, you have to specify the matching name for the parameter you're passing.

    var results = _MiscContext.Database.SqlQuery(
        "exec sp_GetStaff @custid",
        new SqlParameter("custid", customerNumber)).ToList();
    

提交回复
热议问题