ADO.NET vNext Entity Framework documents are back

The documents on ADO.NET vNext that were previously pulled from MSDN have been republished by Microsoft.

I found the links on Steve Eichert's blog (who found them on Fabrice's blog):

I've scanned the documents. Although I don't fully recall the original versions that disappeared, it seems to me that LINQ is featured more prominently in the new versions. In addition to the new SQL variant for querying entities, called Entity SQL, ADO.NET vNext introduces LINQ to Entities.

Some detail as to how LINQ to Entities relates to LINQ to SQL (formerly known as DLinq) was added. The re-alignment of these two new data access technologies at Microsoft doesn't seem complete though. Steve Eichert calls upon Microsoft to not release two competing O/R mapping frameworks and work on integrating them.

LINQ to SQL has its roots in ObjectSpaces, which was first announced at the PDC in 2001. After PDC03 it was merged with WinFS. It later reappeared as DLinq. The DLinq overview document published in September 2005 was subtitled ".NET Language Integrated Query for Relational Data" and talks at length about creating and querying entity classes. It states "DLinq is part of the ADO.NET family of technologies". In hindsight this is an amazing statement, because it is obvious that at the time the DLinq efforts were totally oblivious to the ADO.NET Entity Framework efforts. And conversely, the ADO.NET vNext efforts seemed oblivous to LINQ by introducing yet another query language called Entity SQL.

To fully enable the power of LINQ, ADO.NET vNext should implements the IQueryable<T> interface. The LINQ-fication of the following piece of code from the overview document looks very promising:

using(AdventureWorksDB aw = new AdventureWorksDB(Settings.Default.AdventureWorks))
{
    Query<SalesPerson> newSalesPeople = aw.GetQuery<SalesPerson>(
        "SELECT
VALUE sp "
+
        "FROM AdventureWorks.AdventureWorksDB.SalesPeople
AS sp "
+
        "WHERE
sp.HireDate > @date"
,
        new QueryParameter("@date",
hireDate));

    foreach(SalesPerson p in
newSalesPeople) {
        Console.WriteLine("{0}t{1}", p.FirstName, p.LastName);
    }
}

Using LINQ it can be written as:

using(AdventureWorksDB aw = new AdventureWorksDB(Settings.Default.AdventureWorks))
{
    var
newSalesPeople = from p in aw.SalesPeople
                         where p.HireDate > hireDate
                         select p;

    foreach(SalesPerson p in
newSalesPeople) {
        Console.WriteLine("{0}t{1}", p.FirstName, p.LastName);
    }
}

(Which version do you prefer? 🙂

It is easy to write down the code. To really make this happen, a lot has to happen behind the screens. The type of aw.SalesPeople should implement IQueryable<T>. The C# compiler will then translate the query into an expression tree. The query isn't executed until the newSalesPeople object is enumerated over by the foreach statement. At this point the expression tree has to be translated to T-SQL to be sent to the SQL Server database. As no ADO.NET vNext bits have been released yet, it is not clear if the IQueryable<T> implementation already exists for ADO.NET vNext and/or if ADO.NET vNext will use Entity SQL as an intermediate step.

BTW: The Channel9 video on ADO.NET "3.0" that also disappeared will probably not re-appear. It might be a bit hard to reshoot now that Robert Scoble is leaving Microsoft 😉 I guess it has been superseeded by the Channel9 video with Anders Hejlsberg and Sam Druker.

One thought on “ADO.NET vNext Entity Framework documents are back

  1. Thanks for taking the time for reading the docs.

    Regarding your questions at the end of the blog post:

    Bits: we haven't released bits yet, but we're planning on doing a public CTP around August. We'll be eagerly waiting for feedback once we ship it 🙂

    IQueryable for ADO.NET vNext: the sample you saw in the document actually works in my computer :), and it's working on top of LINQ to Entities and using all of the Entity Framework. I demonstrated it live at TechEd last week as well.

    Entity SQL as an intermediate step: no, LINQ to Entities will not go through Entity SQL; the ADO.NET Entity Framework uses a data-structure-based representation of queries across the stack; Entity SQL is compiled into that structure, and the same happens to LINQ queries. May be some day we'll have time for a talk somewhere like channel 9 on the internals of the new stack.

    Pablo Castro
    ADO.NET Technical Lead
    Microsoft Corporation

    [This posting is provided "AS IS" with no warranties, and confers no rights.]

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *