【发布时间】:2017-04-27 04:36:44
【问题描述】:
我正在使用具有代码优先方法的实体框架。你能提供一些关于如何从我的代码中调用存储过程的建议吗?
存储过程:
create procedure sp_GetCountry
As
Begin
select *
from Country
End
Homectrol.cs:
JanContext db = new JanContext ()
public JsonResult GetCountry_sp()
{
string storedprocedure = "sp_GetCountry";
}
【问题讨论】:
-
旁注:您应该不为您的存储过程使用
sp_前缀。微软有reserved that prefix for its own use (see Naming Stored Procedures),你确实会在未来某个时候冒着名称冲突的风险。 It's also bad for your stored procedure performance。最好只是简单地避免sp_并使用其他东西作为前缀 - 或者根本不使用前缀!
标签: c# ef-code-first