I'm trying to achieve the below:
modelBuilder.Entity<CompanyBranches>().HasQueryFilter(m => !m.IsDeleted);
modelBuilder.Entity<CompanyManagerDetails>().HasQueryFilter(m => !m.IsDeleted);
modelBuilder.Entity<CompanyOwnerDetails>().HasQueryFilter(m => !m.IsDeleted);
modelBuilder.Entity<CompanyPartnerDetails>().HasQueryFilter(m => !m.IsDeleted);
modelBuilder.Entity<TradeLicenseAttachments>().HasQueryFilter(m => !m.IsDeleted);
By using the below so as to stop repetition:
foreach (var pb in modelBuilder.Model
.GetEntityTypes()
.SelectMany(t => t.GetProperties())
.Where(p => p.Name == "IsDeleted")
.Select(p => modelBuilder.Entity(p.DeclaringEntityType.ClrType)))
{
pb.HasQueryFilter(m => !m.IsDeleted); //Bug here due to Type or Delegate issue
}
Basically, I'm trying to avoid entering the queryfilter individually. I want to target all models property (IsDeleted) in order to achieve soft delete