Monday, January 22, 2007

* LINQ : .NET Language Integrated Query

LINQ is a CSharp 3.0 targeted feature which Microsoft is currently working on.

LINQ as Don Box describes : "We use the term language integrated query to indicate that query is an integrated feature of the developer's primary programming languages (e.g., C#, Visual Basic). Language integrated query allows query expressions to benefit from the rich metadata, compile-time syntax checking, static typing and IntelliSense that was previously available only to imperative code. Language integrated query also allows a single general-purpose declarative query facility to be applied to all in-memory information, not just information from external sources."

Lets first see LINQ in action.

using System;
using System.Collections.Generic;
using System.Text;
using System.Query;
using System.Xml.XLinq;
using System.Data.DLinq;

namespace VikasGoyal.FirstLINQ
    class Program
        static void Main(string[] args)
            int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
            IEnumerable<int> lowNums = from n in numbers
                               where n < 5
                               select n;
            foreach (int item in lowNums)



So LINQ makes it possible to apply query to all in-memory information, not just information to external sources.


LINQ CTP May 2006 can be downloaded from here. It gets installed in following dir <System_Drive>:\Program Files\LINQ Preview.

It upgrades the Csharp compiler to support LINQ constructs. It can also be integrated with Visual Studio 2005 by executing following script Install C# IDE Support.vbs found in <System_Drive>:\Program Files\LINQ Preview\Bin folder.

There are few targeted versions of LINQ:

LINQ : query operators as applied to all in memory information.

XLINQ : query operators as applied to XML data.

DLINQ : as applied to relational data

BLINQ : Tool to generate ASP.NET websites based on database schemas. Following use cases are generated : create, update, delete, sorting, paging etc.

No comments:

Post a Comment