Microsoft's new Language Integrated Query (LINQ) technology lets programmers access database and XML data sources by using query extensions that Microsoft has added to the .NET Framework. LINQ addresses one of the biggest disconnects that exists in the current database development model.

In the current scenario, database developers use an object-oriented (OO) language such as C# or Visual Basic .NET (VB.NET) to develop the client application and business objects that exist in the data tier, and ADO.NET is the data access middleware that connects the application with the database. However,when the ADO.NET database code at the core of these programs needs to access the database, the developer must step out of the Visual Studio (VS) OO development methodology and construct a SQL query that's sent to the server.The compiler can't help developers ensure that they've used the right database tables or columns. It can't even check whether the query syntax is correctly constructed because the query isn't actually executed until the application is run.

The new LINQ technology addresses this problem by implementing an object-to-database mapping and providing a set of operators that enable the developer to create database queries directly in .NET code.The SQL-like operators support data retrieval as well as data insert, update, and delete operations—for instance, LINQ provides Select, Where, and OrderBy operators. In this initial release, the Select operator must appear at the end of the clause in C# programs, but in VB programs, Select appears at the beginning as you would expect.

To facilitate the process of database-to-object mapping,the early LINQ beta includes a tool that can generate database tables and classes based on objects in a target database. LINQ doesn't create a sophisticated mapping of one or more relational tables to business objects, rather, it creates a simple one-to-one mapping of relational tables to program objects. It's important to realize that although LINQ enables a new database development model, it's not a replacement for ADO.NET. In fact, LINQ uses ADO.NET, and an application can make use of both LINQ and ADO.NET. Although LINQ provides an OO face to the database, as you might guess, at its core, LINQ is still issuing SQL queries to the database server.

Although LINQ is positioned to create big changes in the future of database development, the current version is still in its infancy. Like the ADO.NET data providers, LINQ providers use an open architecture that enables other database vendors to create providers that work with the LINQ standard. Right now, however, LINQ works only with SQL Server, it doesn't work with Oracle or IBM DB2. Likewise, the initial release runs only on the client. However, the next logical step for LINQ would be to run on the server side with the Common Language Runtime (CLR).

For database developers, LINQ is quite possibly the biggest paradigm change since the advent of ODBC. LINQ eliminates the application-database disconnect and enables full OO database access.You can find more information about the LINQ project at http://msdn.microsoft.com/netframework/future/linq/default.aspx

Michael Otey (mikeo@teca.com), technical director for SQL Server Magazine, is president of TECA, a software-development and consulting company in Portland, Oregon, and coauthor of ADO.NET: The Complete Reference (Osborne/McGraw-Hill).

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

Another ORM tool?

ulisescab

Article Rating 2 out of 5

Um, please do not confuse LINQ with DLINQ, as they are separate things. My whole rant is up on my blog, http://donxml.com/allthingstechie/archive/2006/02/06/2522.aspx but here is the jist of it:

LINQ is defined as "The LINQ Project is a codename for a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities."

LINQ, by itself, has nothing to do with database development technology, but with integrated language query. The query extensions are over any .NET array or collection, not databases. The DLINQ component of the LINQ Project, provides a run-time infrastructure for managing relational data as objects without giving up the ability to query. XLINQ does the same thing, but for XML.

DonXML

Article Rating 1 out of 5