I am using new .net core and EF.
I need help with include linq command. I have some 1:N models and if the collection contais some data marked like deleted I do not w
You can configure a Query Filter in your DbContext.
modelBuilder.Entity<Administrator>()
.HasQueryFilter(admin => !EF.Property<boolean>(admin, "IsDeleted"));
should do the trick
Reference link: https://docs.microsoft.com/en-us/ef/core/querying/filters
You should change the inner condition using Any
instead of Where
, as:
.Include(z => z.WorkPlaces)
.Where(x => x.WorkPlaces.Any(y => !y.IsDeleted))