Architect or Cobbler?
Good code starts with good design

Language Integrated Query (LINQ)

Wednesday, September 14, 2005
I've just been to see one of Anders Hejlsberg's usual high quality talks on this technology, and it looks very interesting to say the least. Linq is not an ORM, it is a query system for the .NET framework, (an Object Query Language if you feel more comfortable) which allows you to query any object that implements IEnumerable on the fly using lambda expressions. Because you can be querying anything the LINQ framework relies on type inference, which of course means you can write var item in C# now. The qualifiers for Linq queries often need to be written as lambda expressions.
var result = from job in Jobs 
             where job.priority > 7
             select job;
foreach (var val in result) {
   Console.WriteLine("{0} is a high priority job",val.Description);
}
  I think the VB would look something like this, but I couldn't swear on it:
Dim result = Select New{ .Description = job.Description, _
                         .Priority = job.Priority } _
               From job In Jobs _
               Where job.Priority > 7
  The LINQ technology also includes two packages for creating Enumerable collections that LINQ can query. DLinq connects to Databases and creates a collection based on mappings, Anders made the claim that this will replace ADO.NET. I'm not 100% sure that this will happen very quickly, and in fact I can think of some occasions where you may not want to think of your data as objects. As with the Wilson ORM mappings are declared using attributes. XLinq, on the other hand is the library that allows for accessing and querying XML data, agin the technology felt familiar to me from using JDOM, a library which treats XML elements and attributes as normal Java collections. For those of you wanting to see more you may want to visit this page I'm keeping a close eye on these technologies though, they are extremely promising. And now to go and see another talk from Anders on the new .NET 3.0 features.

# posted by James @ 11:38 PM   0 comments Comments: Post a Comment

<< Main blog page
This page is powered by Blogger. Isn't yours?