A site devoted mostly to everything related to Information Technology under the sun - among other things.

Saturday, November 17, 2007

Why LINQ Is Important

LINQ is a language feature that allows relational operators to be applied to objects. The obvious use for this is to replace embedded SQL, which is enabled by “LINQ to SQL” (often called DLinq). The biggest win: there is no longer the need for the manual mapping of table names, column names and SQL types to runtime classes, fields and CLR types which has always been extremely tedious and error-prone.

Dlinq requires an explicit mapping, a subtype of DataContext, between the SQL and object world views. Generally, this mapping is created by dropping a SQL model onto a design surface and clicking “OK” a few times. Customization is very easy, though but there are many complexities to object-relational mapping and there will be issues here.

Although the syntax of LINQ is determined by the language designer, not the runtime, in the case of both C# and VB and there are keywords such as select, from, and where that will be familiar to any SQL user.

LINQ additionally supports all the common operators of the relational algebra. This means that, just as a SQL query can result in a table with columns that are mixed-and-matched from the source table, so too can you create objects that are mixed-and-matched from their sources! The implications of that are fairly extensive and lead to concepts such as anonymous types and closures that may be unfamiliar to some, but which are pretty easy to understand in their workaday usage.

LINQ is not an attempt to create a unified data model rather a unified query/manipulation facility. In contrast to DLinq, XLinq 1.0 does not revolve around a strongly typed mapping between the object world and that of XML; a tool for such mapping, called LINQ to XSD, is in development but will not be part of the initial release. (Find out more about LINQ to XSD at blogs.msdn.com/xmlteam/default.aspx.)

Two additional fascinating LINQ technologies are extensions to automatically parallelize LINQ (PLinq) and the use of LINQ and reflection APIs (see tinyurl.com/225pd2). Further, the Dynamic Language Runtime Group at Microsoft (those working on the Iron* languages) point to deep equivalences between LINQ expressions and what they are using to generate code at runtime.

The 1.0 release of LINQ is absolutely something that every CLR developer ought to become familiar with.

No comments:

About Me

My photo
I had been a senior software developer working for HP and GM. I am interested in intelligent and scientific computing. I am passionate about computers as enablers for human imagination. The contents of this site are not in any way, shape, or form endorsed, approved, or otherwise authorized by HP, its subsidiaries, or its officers and shareholders.

Blog Archive