user2516261
user2516261

Reputation: 73

How to use stored procedure in Linq-to-Entities

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

Upvotes: 1

Views: 8567

Answers (2)

Satish Bejgum
Satish Bejgum

Reputation: 223

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

Upvotes: 1

Related Questions