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

Sharepoint tricks

So Alex Henderson, who took over running the Auckland Architecture chats from me, has been busy recently compiling a wiki full of SharePoint Hacks. Hopefully this will grow overtime, but even as it is it is a useful resource. Asad, who has been my peer mentor introducing me to the ways of Microsoft, and I…

1