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
In simple steps:
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
use it by entities.SelectEmployee()
You can check out the following two short articles
http://entityframeworktutorial.net/data-read-using-stored-procedure.aspx
http://entityframeworktutorial.net/EntityFramework4.3/execute-stored-procedure-using-dbcontext.aspx