Wednesday, November 11, 2009

LINQ to SQL Classes tutorial

Step 1:

Add Linq to Sql classes to your application,and make sure you selected the .NET 3.5 as target framework.

Step : 2

Add Server database to solution explorer.After adding Database diagram toggle to find the tables on selected database.

Step :3

Linq to SQL template name will becomes the parent class and retrieve the data from the table as below.


DataClasses2DataContext db2 = new DataClasses2DataContext();
var c = from sp in db.Peoples
select sp;
List li = c.ToList();
GridView1.DataSource = li.ToArray();