Preview: LINQ

Hmmm… a new tool in my hands
… and following equation makes me crazy about it!

C# 2.0 + ADO.NET = LINQ = C# 3.0

In simple words Language Integrated Query (LINQ) exposes the power of SQL queries within C# syntax. This technology along with its tools allows you to connect to SQL database, extract metadata, build typed datasets/classes (using C# Generics) and make you use them along with C# syntax using just two lines of code. And not necessarily SQL databases, it can execute on any collection type.

int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var lowNums =
     from n in numbers
     where n < 5
     select n; Console.WriteLine("Numbers < 5:");
foreach (var x in

Have a look at Linq Project @ MSDN and 101 Samples all to sense this. Here in this short -n-simple post I’m just showing how to do things for databases stored as *.mdf files and generate wrapper classes.The LINQ preview includes SqlMetal.exe, a utility to auto-generate a strongly-typed C# DataContext class file from an SQL Server 2000 or 2005 database’s metadata with this execution syntax:

$>sqlmetal.exe /namespace:NWind /language:csharp /code:Northwind.cs c:\ Northwind.mdf

– Ankit

Tagged on: ,

One thought on “Preview: LINQ

Leave a Reply

Your email address will not be published. Required fields are marked *