Reusing parts of LINQ queries is easily done by chaining methods returning IQueryable. Unfortunately that doesn’t cover some senarios like reusing member initialization lists. To handle such a situation I wrote a Merge extension method for select expressions. For this post we’ll load the data required for a list of cars and a detail view… Continue reading Merging Expression Trees to Reuse in Linq Queries
Tag: Expression Trees
Traversing Expression Trees
The Expression<T> data type which was introduced together with LINQ is interesting. When a Func<TResult> is wrapped in an Expression<T> the code is no longer completely compiled, instead it is preserved as an expression tree that can be traversed during runtime. This is what the method ExpressionHelper.GetExpressionText() that I used in my last post Type Safe SelectList… Continue reading Traversing Expression Trees