Sunday, May 03, 2009
« .Net Road Trip to Québec City - Jean-Ren... | Main | Joël Hébert Named SQL Developer Stream D... »

Yesterday I had the pleasure to present at the Ottawa Code Camp.I showcased something quite interesting and got alot of feedback on it.



In Entity Framework you can stronly type your linq to sql includes by adding Extension Methods. I found just methods as I was perusing the net one day.

Extension Method

Later on I discovered that the possiblitily to daisy chaine these strongly typed incudes could be done by daisy chaining lambda expressions. .This can be acheived with this Extension Method from the same author.

Extension Method for multiple includes

The lesson to retain is that the compilation is going to catch the erroneous fields if they are altered or missing , and not the user at run-time.

Here is the semantical variance:

NORTHWNDEntities ctx = new NORTHWNDEntities();

var Category_Products_EagerLoad = ctx.Categories.Include("Products");

//VS

var test = ctx.Categories.Include(c => c.Products);

Sunday, May 03, 2009 12:05:06 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |  Trackback Related posts: