Paul Gielens:ThoughtsService

another Endpoint to my thoughts

News

Syndication

Ads


Favorites

Projects

Clearing up Query technologies in .NET vNext

Regular SQL doesn’t have the constructs required to deal with the elements available in the Entity Data Model (EDM). For this reason the ADO.NET Entity Framework introduces a new query language called Entity SQL. Entity SQL queries looks pretty much like regular SQL since the structure is the usual SELECT-FROM-WHERE sequence. Entity SQL is designed to leverage the full expressiveness of the entity data model.

Query<SalesPerson> newSalesPeople = aw.GetQuery<SalesPerson>(

    "SELECT VALUE sp " +

    "FROM AdventureWorks.AdventureWorksDB.SalesPeople AS sp " +

    "WHERE sp.HireDate > @date",

    new QueryParameter("date", hireDate));

Please note that in this example the query uses the conceptual EDM schema in which the SalesPerson entity maps to the SalesPerson, Employee and Contact table.

Linq to Entities raises the level of abstraction to manipulate data in application code. It allows you to formulate your queries directly within the programming language itself. Say goodbye to string literals that cannot be understood or verified during compilation. The same query now LINQ-ified with compile-time validation:

var newSalesPeople = from p in aw.SalesPeople

                     where p.HireDate > hireDate

                     select p;

When to use what? Applications based on the Domain Model pattern would probably consume ADO.NET’s Object Services and use Linq to Entities.

[edit]
Entity SQL is targeted at application scenarios that require a more dynamic mechanism to formulate queries. Entity SQL is optimized to take advantage of and expose concepts in the EDM.

Posted: Aug 15 2006, 11:22 PM by p.gielens
Filed under:

Comments

No Comments