Thursday, May 10, 2007

LINQ

At the Microsoft Professional Developers Conference (PDC) 2005, Anders Hejlsberg and his team presented a new approach, Language-Integrated Query (LINQ), that unifies the way data can be retrieved in .NET. LINQ provides a uniform way to retrieve data from any object that implements the IEnumerable interface. With LINQ, arrays, collections, relational data, and XML are all potential data sources.

LINQ to Objects is an API that provides methods that represent a set of standard query operators (SQOs) to retrieve data from any object whose class implements the IEnumerable interface. These queries are performed against in-memory data.

LINQ to ADO.NET augments SQOs to work against relational data. It is composed of three parts (which appear at the bottom level of Figure 1): LINQ to SQL (formerly DLinq) is use to query relational databases such as Microsoft SQL Server.

LINQ to DataSet supports queries by using ADO.NET data sets and data tables. LINQ to Entities is a Microsoft ORM solution, allowing developers to use Entities (an ADO.NET 3.0 feature) to declaratively specify the structure of business objects and use LINQ to query them.

LINQ to XML (formerly XLinq) not only augments SQOs but also includes a host of XMLspecific features for XML document creation and queries.

Requirements

LINQ is a combination of extensions to .NET languages and class libraries that support them.

To use it, you'll need the following:

• LINQ, which is available from the LINQ Project website at
http://msdn.microsoft.com/data/ref/linq. I've used the May 2006 CTP for this book.
• NET 2.0 running on Windows 2000 (Service Pack 4), Windows Server 2003, Windows XP
Pro (Service Pack 2), or Windows Vista.
• To write C# programs using LINQ, you need either Visual Studio 2005 or Visual C#
2005

Express Edition.
• To use LINQ to ADO.NET, you need SQL Server 2005, SQL Server 2005 Express Edition,
or SQL Server 2000.
• If you want to use LINQ with .NET 3.0 (originally WinFX), you need the WinFX
Runtime

Resources

There's a lot of good material available about LINQ:
• The LINQ May 2006 CTP includes a complete set of documentation.
• The main LINQ Project site (http://msdn.microsoft.com/data/ref/linq) includes a
Forums section where thousands of developers discuss LINQ, ask for support, and
report bugs.
• At http://shop.ecompanystore.com/mseventdvd/MSD_Shop.asp you can order the DVD
that contains full sessions from PDC 2005, where LINQ was unveiled.
• On the Channel 9 site (http://channel9.msdn.com), Anders Hejlsberg and his team are
often interviewed about LINQ issues and development.
Beta 2.

No comments: