LINQ—The Missing Piece of Database Development

Microsoft's new Language Integrated Query technology lets programmers use new query extensions to the .NET Framework to access database and XML data sources.

Michael Otey

December 19, 2005

3 Min Read
ITPro Today logo in a gray background | ITPro Today

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 ([email protected]), 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).

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like