如何将参数传递给我在MVC4中连接到Entity Framework的存储过程 [英] How to pass Parameter to stored procedure which i am connected to Entity Framework in MVC4
问题描述
我的程序我必须将公司详细信息插入数据库,并且我已经存储了proc以进行插入和更新。我在我的存储过程中提到了类型参数I和U(即插入和更新)。基于从前端操作传递的类型应该执行。我已通过实体框架连接Db
I my program i have to Insert the Company details to Data base ,and i have stored proc to insert and update .I have mentioned Type parameter I and U (i.e insert and update) in my stored proc. Based on the type passed from front end operation should perform . I have connected Db through Entity framework
private PTMEntities1 db = new PTMEntities1();
和我的帖子方法
And my post method
[HttpPost]
public ActionResult Company(Company comp)
{
Guid companyId = new Guid();
comp.CompanyId = companyId;
Guid createdBy =new Guid( "6B2FA75B-8A7F-4CF2-BBF7-9C5728308E0C");
comp.CreatedBy = createdBy;
db.Companies.Add(comp);
db.SaveChanges();
return View(comp);
}
}
我必须在这里传递类型。
获取错误错误1错误2037:映射函数绑定指定函数PTMModel.Store.Company_Insert_Update但不映射以下函数参数:类型。 D:\Checked pro's\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\我通过MVC4中的实体框架连接。
请仔细阅读。建议我提出任何想法。
在此先感谢...
I have to pass type here .
Am getting error Error 1 Error 2037: A mapping function bindings specifies a function PTMModel.Store.Company_Insert_Update but does not map the following function parameters: Type. D:\Checked pro's\ATSSample\ATSSample\Models\Model1.edmx 1259 17 ATSSample
Am not getting how to pass parameter to stored proc which i connected through Entity Framework in MVC4 .
Please look through this .suggest me any idea .
Thanks in advance ...
推荐答案
嗨Karthik,
您可以参考在其中 [ ^ ]连接/映射存储过程到你的mvc应用程序。
希望这对你有所帮助。
问候,
RK
Hi Karthik,
You can refer here[^] to Connect/map store proc to your mvc application.
Hope this helps you a bit.
Regards,
RK
这篇关于如何将参数传递给我在MVC4中连接到Entity Framework的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!