Giving the next model:
public class User{
public int IdUser { get; set;}
public virtual ICollection<Project> Projects { get; set;}
public virtual ICollection<Exam> Exams { get; set;}
}
public class Project{
public int IdProject { get; set;}
public bool Current { get; set;}
public virtual User { get; set;}
}
public class Exam{
public int IdExam { get; set;}
public int score { get; set;}
public virtual User { get; set;}
}
I need to get the projects with current=true and exams with score greater than 4 from a given user.
When i need to filter a navigation property, for avoiding bringing all the records and apply the filter in memory, i do the next:
IQueryable<Project> = context.Entry(user).Collection(x => x.Projects).Query().Where(n => n.Current).ToList();
On that way, i bring from the database only the current projects. Avoiding the other way of retrieving all the projects to memory and then applying the filter on memory.
So now, i want to do the same (bring only the records that matters), but i don't know how can i do that when i have more than one collection.
Can you help me? Thanks!