Answer the question
In order to leave comments, you need to log in
How to dynamically generate conditions in Entity Framewrok?
How can I dynamically generate query conditions?
Answer the question
In order to leave comments, you need to log in
Yes, just throw them to IQueryable:
IQueryable<Person> query = context.Persons;
if (searchByFirstName)
query = query.Where(x => x.FirstName == someFirstName);
if (searchByAge)
query = query.Where(x => x.Age == someAge);
var persons = query.ToList();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question