Sunday, June 18, 2006

[Upated September 30, 2006]

At first glance one might think that the new LINQ technology is a direct competitor to the EntitySpaces architecture; however that would not be a correct assumption. The LINQ Project is a codename for a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities. EntitySpaces LLC has added the ability to use the LINQ syntax against EntitySpaces collections as of our 1.5 release.

As LINQ nears its official release we will look at translating the LINQ IQueryable<T> expression trees into our query API. In fact, when LINQ is first released it will support SQL Server only and rumor has it that LINQ is still a year or more out though Microsoft hasn't stated a release date yet. 

Have a look at this example: 

EmployeesCollection coll = new EmployeesCollection ();
coll.LoadAll();
// All employees with "i" in the last name ordered by FirstName in decending order
var emps = from e in coll
where e.LastName.Contains("i") orderby e.FirstName descending select e; foreach(Employees emp in emps) { Console.WriteLine(emp .FirstName + ", " + emp.LastName); }

It is even possible to derive your own result sets via the LINQ query against an EntitySpaces collection.


EmployeesCollection coll = new EmployeesCollection();
coll.LoadAll();

// All employees with "i" in the last name ordered by FirstName in decending order
var emps = from e in coll
                where e.LastName.Contains("i") 

                orderby
e.FirstName descending
                select
new { e.FirstName, e.LastName };

foreach(var dude in emps)
{
    Console.WriteLine(dude.FirstName + ", " + dude.LastName);
}

Some links you'll find useful:
Using LINQ with ASP.NET   (Part 1)
Using DLINQ with ASP.NET (Part 2)