Microsoft is going to release a new data retrieval technology called LINQ(Language Integrated Querying). You will be able to write queries in C# and VB as you write any other code. The data is retrieved from the database, converted to objects(like a typical O/R mapper) and queried from C# code.
Here is the sample:
//Created by the designer
DataContext db = new DataContext();
//Querying Products table in Northwind database
var query = from p in db.Products
select p;
//Iterating all the rows
foreach(Product pr in query)
{
Console.WriteLine(pr.ProductName);
}
You can create the LINQ objects using the designer and generate the required classes.(Notice the DataContext and Product classes in the above sample. This class will be generated when you drag and drop the tables from the server explorer into the designer.)
You can download the May 2006 Community Tech preview version of LINQ from here. Also the new "Orcas" March CTP will have the built in support for LINQ .
Wednesday, February 28, 2007
Subscribe to:
Posts (Atom)