[英]How to call stored procedure in EF code-first approach?
我正在使用实体框架和代码优先的方法。 你能提供一些关于如何从我的代码调用存储过程的建议吗?
存储过程:
create procedure sp_GetCountry
As
Begin
select *
from Country
End
Homectrol.cs
:
JanContext db = new JanContext ()
public JsonResult GetCountry_sp()
{
string storedprocedure = "sp_GetCountry";
}
public JsonResult GetCountry_sp()
{
// string storedProcedure = "sp_GetCountry";
var Country = db.Countries.SqlQuery("sp_GetCountry").ToList();
return new JsonResult { Data = Country, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.