For Advance Asp.net Training Fill Enquiry Form
LINQ to Stored Procedure
LINQ also provide facility to connect with Stored Procedure. Following is the table which I am using to explain this topic.
To work with LINQ to SQL we have to add LINQ Classes. Using Add New Item add LINQ to SQL Classes.
Now create class to map with Table Emp
public class Class1
//IsDbGenerated represents that it is Identity column
public int id;
public string name;
public int age;
Follow the following steps:-
Create Stored Procedure
create proc selectAllData
select * from emp
To work with stored procedure in LINQ we have to use DataContext class. To run stored procedure we have to use ExecuteMethodCall which is protected type. So we have to first inherit the DataContext Class to call the method ExecuteMethodCall ().