What Is LINQ to SQL?
LINQ to SQL is an (object relational mapping) implementation that ships in the .NET Framework "Orcas" release, and which allows you to model a relational database using .NET classes. You can then query the database using LINQ, as well as update/insert/delete data from it.
LINQ to SQL fully supports transactions, views, and stored procedures. It also provides an easy way to integrate data validation and business logic rules into your data model.
Modeling Databases Using LINQ to SQL:
Visual Studio "Orcas" ships with a LINQ to SQL designer that provides an easy way to model and visualize a database as a LINQ to SQL object model.
Using the LINQ to SQL designer I can easily create a representation of the sample "DataClasses2.dbml" database like below:
After connect to Data connections track and drop the database table and stored procedure here,
LINQ CODE EXAMPLE:
Public partial class Samplelinq: System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
samplelclassDataContext smlinq=new samplelclassDataContext ();
var sq = from lq in smlinq.MASSes select lq;
GridView1 .DataSource =sq ;
GridView1 .DataBind ();