Fri, Sep 16 2005 3:08 AM
Rob van der Meijden
PDC 2005 Linq, DLinq, XLinq and C# 3.0
Inspired by the key-note I went to the sessions about “LINQ” (.NET language integrated query) and “C# future directions in language innovation” to see more of the possibilities. So, here is a little summary of two sessions by Anders Hejlsberg.
Linq is the SQL integration for all classes which implement the IEnumerable<T>.In a demo Anders showed us the power of using a query language on a collection. For example; take a customer collection in mind, order them by name, select only one state and create a join with a different collection within … in just a few lines of code … not to mention that’s its all type safe.
DLinq (Date Linq) can be seen as the next version of ADO.NET. Using attributes above classes relate a class to a database model. DLinq can communicate directly to you’re database or with the help of classes. These classes can either been generated as a partial class or been written by you. You can choose to use SQL queries generated (efficient; only that columns are used which are selected) by DLinq or use stored procedures (no plans for automatic generation).
XLinq (Xml Linq) is the query language again XML DOM documents which makes it much easier the do queries on XML data. When you’ve a collection you can also create XML document in a very easy way. The current downloads contain a sample application where all the possibilities of Xlinq and Dlinq are expressed in scenarios.
One of the design goals for C# 3.0 is “Integrate objects, relation and XML”; pretty necessary when you are creating Linq. Anders went geeky on all this new features as Lambda (c => c.Name), Extension methods (static void Dump(this object o);), local variable type inference (var x = 5;), Object initializers (new Point { x = 1, y = 2 }), Anonymous types (new { c.Name, c.Phone }), Query expressions (from … where … select) and Expression trees (Expression<T>). I admit … at some points he lost me …
Linq resources from Barry Gervin, thx. Ramon
Filed under: PDC