我使用实体框架采用代码优先方法。你能提供一些关于如何从我的代码中调用存储过程的建议吗?
存储过程:
create procedure sp_GetCountry
As
Begin
select *
from Country
End
Homectrol.cs
:
JanContext db = new JanContext ()
public JsonResult GetCountry_sp()
{
string storedprocedure = "sp_GetCountry";
}
答案 0 :(得分:1)
public JsonResult GetCountry_sp()
{
// string storedProcedure = "sp_GetCountry";
var Country = db.Countries.SqlQuery("sp_GetCountry").ToList();
return new JsonResult { Data = Country, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
答案 1 :(得分:1)