Rolling your own SQL Update on-top of the Entity Framework – Part 1

One of the current limitations of the Entity Framework, is that in order to modify an entity you have to first bring it into memory. Now in most scenarios this is just fine. There are however some bulk update cases where performance suffers somewhat. For example imagine if you need to move all unshipped orders…

4

Dude where is my query going to run?

One of the key decisions with LINQ to Entities (L2E) is that all predicates in an L2E expression must be converted into store expressions, so that the store does all the heavy lifting. This means for example if you try the following: var matches = from e in ctx.Employees               where IsTopPerformer(e) && e.FirstName.StartsWith(“C”)              …

1

T CastByExample<T>(object o, T example)

So earlier today I was lamenting that an anonymous type can’t be shared between functions with Wes Dyer, when he said “Well actually they can…” Cue me learning something cool. The first step is to create a seemingly innocent method: public static T CastByExample<T>(this object o, T example) {     return (T) o; } Seems…

15

Compiled Queries and the EntityFramework

For a while LINQ to SQL has had compiled Queries… and now in Beta3 of the Entity Framework, due out soon, we have them too. The idea behind compiled queries is that you don’t want to re-process the same LINQ expression every time it is encountered. Instead you want to pre-compile the LINQ expression, so…

2

CommandBehavior.SequentialAccess

So why does this: EntityDataReader reader  = command.ExecuteReader(); Throw an exception? Well it is to-do with correctness and setting expectations. First things first, this is what you should do: EntityDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess); But why? What this does is explicitly open the reader the only way we currently support: sequentially. Which begs two questions: What does opening…

4