Important Entity Framework Query Improvements for .NET 4.0

Kati Iceva, the gal I know as the brains behind query compilation for Entity Framework (though she may have some partners in crime) has written a great blog post laying out some of the improvements to query generation in EF4.

Improvements to the Generated SQL in .NET 4.0 Beta1

Kati explains 7 major changes in detail with before & after examples and lists an additional set of changes we will see after Beta 1.

Here is my abbreviated version of  the changes she lays out:

  1. More efficient nested queries
  2. Eliminated unnecessary Is Null checks in LINQ to Entities queries
  3. Bye bye to some of the crazy LEFT OUTER JOINs
  4. Streamlining nested ORs with IN
  5. Support for more variations on LINQ’s GROUP BY operator
  6. Stop Casting 1 to a bit of 1
  7. Greatly simplifying queries against hierarchical entities

Her additional list of upcoming changes has two which I want to highlight because after SQL MVP, Adam Machanic, pointed this out to me, he and I lobbied hard for a fix.

 

  • Improve the translation of the functions String.StartsWith, String.Contains and String.EndsWith in LINQ to Entities to use LIKE.
  • Improve the translation of the canonical functions StartsWith, Contains and EndsWith to use LIKE (these canonical functions became available in .NET 4.0 Beta1)

    Entity SQL does have a LIKE statement and I have recommended frequently that people use it instead of the above functions if they care about database performance.

    If *you* care about your database performance, don’t miss this blog post.

    Note that Kati points out which improvements only impact SqlClient and which are in the query pipeline and will help all providers.

     

  • #1 ravi tejas on 3.04.2010 at 12:50 AM

    nice to hear the improvements, but i have a concern, i am using entity framework 3.5, visual studio 2008 and developing web applications. in 2.0 framework, just by changing the connection string in web.config, the application woudl work, but using entity framework and generating the .edmx model, every connectio nstring change, i need to rebuild and republish the web application and this is big limitation, can you suggest any methods to avolid this situation or .net 4.0 any improvements being done.

    Leave a Comment