如何在Linq-to-Entities中使用存储过程 [英] How to use stored procedure in Linq-to-Entities
本文介绍了如何在Linq-to-Entities中使用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用实体框架
我想知道如何在Linq-to-Entities中使用存储过程。我的存储过程称为 SelectEmployee
,表名为员工
I want to know how I can use stored procedures in Linq-to-Entities. My stored procedure is called SelectEmployee
and table name is Employee
为此我添加了这样的代码
For this I added code like this
databaseentity entities = new databaseentity();
var selectdata = entities.ExecuteStoreQuery<Employee>("SelectEmployee").ToList();
但不支持 ExecuteStoreQuery
所以请指导我如何在Linq-to-Entities中使用存储过程
So please guide me how can I use stored procedures in Linq-to-Entities
推荐答案
简单的步骤:
-
将您的存储过程添加到edmx。
Add your stored procedure to the edmx.
您将在模型浏览器中找到该文件
You will find that sp in Model Browser
右键单击存储过程,并说出添加功能导入
Right click on stored procedure and say Add Function Import
使用 entities.SelectEmployee()
这篇关于如何在Linq-to-Entities中使用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文