Behind the seen Link to SQL provider converts LINQ query to normal SQL query, which is understands by SQL server database.
Here Stored Procedure name is Get All Employees, therefore we will get the Get All Employees() method.
We can directly call this method using db Context object. CREATE PROCEDURE Insert Employees @ Emp ID integer, @ Emp Name varchar(100), @ Gender varchar(50), @ Salary money, @ Address varchar(200), @ Dep ID integer AS BEGIN -- Insert statements for procedure here insert into tbl Emps values(@ Emp ID, @ Emp Name , @ Gender , @ Salary , @ Address , @ Dep ID ) ENDCREATE PROCEDURE Update Employees @ Emp ID integer, @ Emp Name varchar(100), @ Gender varchar(50), @ Salary money, @ Address varchar(200), @ Dep ID integer AS BEGIN update tbl Emps set name=@ Emp Name, Gender=@ Gender , Salary=@ Salary , Address=@ Address , Dep ID=@ Dep ID where Emp ID=@ Emp ID END Now refresh the Data Connection on server explorer and drag these stored procedure on desiner pane as we have already done with select stored procedure.
In LINQ, the same query can be used in, an SQL database, a Data Set, an array of objects in memory and so many other data types.
Link to SQL is Object Relation Mapping (ORM) framework.
It creates the strongly typed dot net classes based on database tables.
LINQ to SQL enables you to write Select, Insert, Update, Delete query after after strongly typed dot net classes generated.Database will be added under Data Connections as shown below. If primary key & foreign key relations are there then it will automatically displayed. Click on Emp.file, you will see Emp Data Context class that is inherited from Data Context class.Remember that we have created the file and it will generate the Emp Data Context class.Select your stored procedure and drag it on the designer pane.In LINQ to SQL if you drag Stored Procedure on designer pane, it will converted to method.You can easily see the sql query, which is generated by LINQ to SQL. Now open the file that we have already created in previous example.