Improvements in Entity Framework 4.0

   With .NET 4.0 a lot of new features and technologies will see the light, as long as others will get improved, and Entity Framework will be one of those technologies that will get improved.

   A lot of this changes are being made on the Query pipeline, that means that are being done on the translation from Linq to SQL code, and some of the changes in Beta 1 are the following:

  1. Avoid projecting all columns in nested queries
    • Instead of making a query for the complete set of columns and the make the projection on top of it, just make the projection and get only the needed columns
  2. Avoiding Unnecessary IS NULL Checks in LINQ to Entities Queries
    • remove the Is null check when using Joins
  3. Additional join elimination:  Eliminate parent table in “Child Left Outer Join Parent”
    • Avoid having a child left outer join if no column from that relation is needed for the projection
  4. Using IN instead of nested OR’s
    • Instead of having several Or’s in place such as “CategoryId = 1 OR CategoryID = 2 (…)” have “CategoryId In (1,2,…)”
  5. Translating more of LINQ’s GroupBy operator into GROUP BY
    • Better use of the SQL Group By in order to simplify the query
  6. Avoiding “Cast (1 as bit)”, using “1” instead
  7. Simplifying some queries that go against a subtype in a type hierarchy

   Some of the changes after Beta 1:

  1. Elimination of null sentinels
    • In the output query there is often the constant 1 projected both in nested and in top-most queries. By avoiding it and reusing other columns for the same purpose in many cases we are able to avoid levels of nesting.
  2. Additional Join Elimination
  3. Use of Inner Joins instead of Left Outer Joins when possible
  4. Provide mechanism for efficient queries on non-Unicode columns
    • We now generate non-unicode constants and parameters when these are used in LINQ to Entities queries in comparisons with non-unicode columns. This allows indexes to be used by SQL Server.
  5. Improve the translation of the functions String.StartsWith, String.Contains and String.EndsWith in LINQ to Entites to use LIKE.
  6. Improve the translation of the canonical functions StartsWith, Contains and EndsWith to use LIKE (these canonical functions became available in .NET 4.0 Beta1)
  7. Collapse multiple Case statements into one

   You can read more about this topic on this ADO.NET Team post.

Interesting Diagram Generation Controls

Some time from now I was searching for controls that would made the generation of diagrams of several kinds, like for instance::

  • Network Diagram
  • Worlflow Diagram
  • Database Diagram
  • Hierarchy Diagram

  Basically I was trying to find a control that would solve the problem of having to search for different controls depending on the type of diagrams I would need in my projects, an in this case the project was in Silverlight. After a lot of research and a lot of CodeProject and others that would just fit a specific problem, I came across one that solved exactly what I was needing, and I found it on MindFusion named DiagramLite.

  The DiagramLite is a quite interesting control since it provides a way for us to make available any kind of diagram in Silverlight and with the possibility of editing that diagram, and this makes it possible to create a new Workflow designer for our solutions using Silverlight. (Of course I now that this was done without this control, but it seems to me that it would be a lot easier with it, but this is just from my experience).

  You can find samples here.

  Along with the Silverlight version I also found that they also have several other versions for WPF, WinForms, ASP.NET, .Net Compact Framework and even Java, and for this it seems that they are pretty experts into the Diagram controls, and it’s pretty interesting since their support is pretty quick as well as clear.

  I hope this post comes handy for you, since when it was me I had to to do a lot of searching and testing for several possibilities.

ADO.NET Data Services

As I already explained in a previous post, ADO.NET Data Services are very interesting since they generate a layer on top of our data model in a REST accessible way. Being this technology without any doubt very interesting and very helpful when building our solutions, we don’t always remember the notation that we should use in order to execute actions like:

  • Sorting – orderby
  • Filtering – filter
  • Selection of only a determined set of elements – Top
  • Ignore a set of records – Skip
  • Make String operations
    • substring
    • endswith
    • startswith
    • length
  • Make Date operations
    • day
    • month
    • year
    • hour
    • minute
    • second
  • Make Math operations
    • round
    • floor
    • ceiling
  • Make Type operations
    • isof
    • cast

If you’re like me, you never remember the exact notation to use, and for this reason I reminded that it could be interesting to place here a link for the ADO.NET Data Services Datasheet provided by Robert Maclean.

And once again thank Robert for his excellent job into creating this Datasheet that comes so handy.