(Code below has been updated and worked properly)
There is dynamic OrderBy sample from LinqPad. What I want to do is just simply apply \'Where\' rather than \'OrderB
Use the lambda that Jon Skeet supplied. Perhaps he can also explain why ParameterExpression
is so painful to use and requires using the same instance, instead of being able to be matched by name :)
Modify this line:
Type[] exprArgTypes = { query.ElementType };
exprArgTypes
is type parameters to
IQueryable Where(this IQueryable source, Expression> predicate).
As you can see it only has one type parameter - TSource
, which is Purchase
. What you were doing, effectively, was calling Where
method with two type parameters like below:
IQueryable Where(this IQueryable source, Expression> predicate)
Once both of those fixes are in the expression runs with no problem.