LINQ to SQL is designed to support ordering by simple primitive types, such as string, int,datetime and so on, for this example I have taken Orders and Customers tables in Northwind Database.
Linq to Sql given us excellent feature of joins, the two common joins are the inner join (or just join in LINQ) and the left join. Inner join returns all the rows that are matched in both tables, left join returns all rows from the left table, even if there are no matches in the right table
Sample pieces for inner join and left join
Inner Join
var empDetails = from emp in objEmp.Employees
join dept in objEmp.Depts on emp.Deptid equals dept.DeptId
selectnew
{
emp.EmpName,
emp.Designation,
emp.Location,
dept.DeptName
};
Left Join
var empDetails = from emp in objEmp.Employees
join dept in objEmp.Depts on emp.Deptid equals dept.DeptId into empdet
Right click on Solution explorer click on add new item. Here you will find dbml classes add dbml class named as EmployeeDept
Now we need to connect sqlserver through Server Explorer, if you do not find server explorer on left side corner please go to view and select server explorer
right click on dataconnections in Server explorer click on add connection.
you will have a option to choose data source type, for our project we have selected Microsoft SqlServer then click on continue.
Here we need select Server name and Database Name once you have selected Server name and Database Name test connection weather succeed.
Once finished the connection with SqlServer you can get all the tables and Stored procedures.
Just drag and drop Tables and Stored Procedures on the dbml Class Surface.visual studio automatically creates properties for table and methods for stored procedures.
Inserting Record
copy and paste flowing html code in asp page.here i have taken three textboxes, one dropdownlist and one button.