1、首先从实体数据模型右击“从数据库更新模型”,选出你要执行的存储过程。
微信截图_20190525223922.png
2、可以看出实体数据模型 下面多了一个以存储过程名称命名的实体类。
微信截图_20190525224008.png
3、控制器实现。
public ActionResult ProcSelect(int page, int limit, string SearchName)
{
using (GZ_CRMEntities db = new GZ_CRMEntities())
{
var count = new ObjectParameter("count", typeof(Int32));
//count.value 即为执行存储过程的输出参数
bool difference = true;
int emp_id = 1;
var data= db.Search_ServceTable(page, limit, count, difference, SearchName, emp_id).ToList();
//Search_ServceTable 即为存储过程名称
return Content(JsonConvert.SerializeObject(data) );
}
}