How to use stored procedure in Linq-to-Entities

entity-framework linq

Question

I am working with Entity Framework

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();

but it is not supported ExecuteStoreQuery

So please guide me how can I use stored procedures in Linq-to-Entities

1
1
6/29/2015 6:52:19 PM

Accepted Answer

In simple steps:

  1. Add your stored procedure to the edmx.

  2. You will find that sp in Model Browser

  3. Right click on stored procedure and say Add Function Import

  4. use it by entities.SelectEmployee()

1
7/11/2013 10:11:47 AM



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow