I plan to prepare some methods that returned to me an already filtered collection of elements in the database table, and then execute queries in these collections. I am wondering if the first filtering will be performed as a separate statement or whether it will be combined.
eg.
public IQueryable<Person> GetAlivePersons(){
return db.Persons.Where(p => !p.IsDeceased);
}
public IQueryable<Person> GetElderPeople(){
return GetAlivePersons().Where(p => p.Age > 75);
}
Will the second method get into the database once or twice?
thank
source
share