Building 'flat' rather than 'tree' LINQ expressions
- by Ian Gregory
I'm using some code (available here on MSDN) to dynamically build LINQ expressions containing multiple OR 'clauses'.
The relevant code is
var equals = values.Select(value => (Expression)Expression.Equal(valueSelector.Body, Expression.Constant(value, typeof(TValue))));
var body = equals.Aggregate<Expression>((accumulate, equal) =>…