Skip to content

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
lowNums)
{
    Console.WriteLine(x);
}

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

One Comment

  1. manu

    In simple words Language Integrated Query (LINQ) exposes the power of SQL queries.
    ____________________
    Manu
    Digital Infosys

    Posted on 16-Jul-08 at 1:43 pm | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image