2

I have the line below, and thinking to filter the CustomersPics isdeleted == true. How do I do that?

List<Customer> _customer = context.Customers
                                  .Where(r => r.IsDeleted == IsDeleted)
                                  .Include(r=> r.CustomersPics)
                                  .ToList();
CodeNotFound
  • 22,153
  • 10
  • 68
  • 69

1 Answers1

1

You can't do what you want with Include extension method. You can filter the navigation collection property by using Load method like this:

var customers = context.Customers.ToList(); // Make to add some Where clause here and avoid loading all data from Customer table :D
foreach(var customer in customers)
{
    context.Entry(customer)
           .Collection(p => p.CustomersPics)
           .Query()
           .Where(p => p.IsDeleted == true)
           .Load();
}
CodeNotFound
  • 22,153
  • 10
  • 68
  • 69