I want to do something like that;
Context.Users.Include("Addresses", a => a.IsRowDeleted == false).FirstOrDefault(u => u.UserId == 5);
I mean; I want to filter included entities but not always, its also have to be optional.
What is the best solution for this? Please help me,
You cannot filter eager loaded data in EF.
Includeoperation doesn’t support filtering or sorting.You must use either projection to custom type (or anonymous type):
Or you must devide your query into two separated queries and use explicit loading:
Or you can simply use two queries: