Wednesday, July 9, 2008

LINQ to SQL in C#

This article provides an introduction to employing LINQ to SQL within a Windows Forms application.
Article will address the incorporation of LINQ to SQL into a win forms project, how to use LINQ to SQL to select, insert, update, and delete data, and how to use LINQ to SQL to execute stored procedures.


The article shows some simple examples of LINQ to SQL; from it you can see how easy it is to query against single and related tables and to write filtered queries, execute stored procedures, perform aggregation, and how to insert, update, and delete records from the database.


DataClasses1DataContext dc = new DataClasses1DataContext();
var q =
from a in dc.GetTable()
where a.CustomerID.StartsWith("A")
orderby a.OrderDate ascending
select a;
dataGridView1.DataSource = q;


click here for full article