Geeks With Blogs
Mark Nichols' Blog Let me explain. No, there is too much. I will sum up.

I went to a presentation on Microsoft’s next set of language extensions (C# 3.0 and VB 9) called LINQ – Language INtegrated Query.  It will give the developer the ability to write C#/VB code that does data (not just database) manipulation within the application with a SQL-like syntax.  The purpose is to link (traditional spelling) the object-oriented world with the relational and/or hierarchical worlds.

 

Example:

int[] nmbrs = {10, 12, 18, 2, 5, 11, 8, 6, 4, 1};

 

var gtTen = from n in nmbrs

            where n > 10

            select n;

 

The result puts {11, 12, 18} into gtTen.

 

“n” is an alias for the data being retrieved from nmbrs.  The syntax is very similar to SQL but not exactly - the first indicator is that the “from” clause comes first.  It needs to be so that intellisense will work properly.  If it started with “select n” intellisense would not have a clue what n was.

 

There is one new enabling language extension to note here.  “var gtTen” uses type inference to create a variable of the proper type based on what is returned on the right side of the equals sign.  In this case the gtTen variable will end up with the type integer array.  There are several new enabling extensions that all help to make LINQ work but that is out of scope for this blog.

 

The above simple example shows the extension used on an internal data structure.  The syntax can also be used to retrieve data from a database or XML store.  It also does partitioning, aggregation/grouping, ordering, set operations, etc.

 

Although this future extension is described by some as “revolutionary” (a word not too overused) it worries others by giving the ability to move functionality, usually controlled by the data tier, into the code where changes and control is harder to manage.  Yes, it is an extremely powerful extension in that it works not only on a database but also on internal application data structures using the same syntax.  But, will it corrupt all that dare to utilize the new capabilities?  If you let it, it will. 

 

As in every situation where the difficulty of performing certain functions is reduced with language extensions, the proper use is still lies in solid design decisions.  It would be wrong to pull control operations typically performed in a database into the code just because you can.  Use the capability wisely and it will (most likely) give you the ability to do more with less code.  Violate standard development practice and you will end up with an application that is difficult to manage and performance that will frustrate all but the most patient.

 

Posted on Friday, October 21, 2005 11:22 AM .NET Observations | Back to top

Related Posts on Geeks With Blogs Matching Categories

Comments on this post: Will LINQ Corrupt Us All?

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Mark Nichols | Powered by: GeeksWithBlogs.net