Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
I pass parameter to Where method as follows: f => f.Id > 4.
Can I pass a delegate method instead of f.Id > 4?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
The Entity Framework needs to be able to see everything that is being attempted.
So if you simply did something like this:
Where the definition of DelegateFunc looks like this:
The Entity Framework has no way of peering inside the delegate, to crack it open and convert it to SQL.
All is not lost though.
If your goal is to re-use common filters etc you can do something like this instead: