Skip to content

Support multiple HasQueryFilter calls on same entity type #10275

@nphmuller

Description

@nphmuller

As of 2.0 multiple HasQueryFilter() calls on EntityTypeBuilder result in only the latest one being used. It would be nice if multiple query filters could be defined this way.

Example:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<MyEntity>()
        .HasQueryFilter(e => e.IsDeleted == isDeleted)
        .HasQueryFilter(e => e.TenantId == tenantId);
}

// In application code 
myDbContext.Set<MyEntity>().ToList() // executed query only has the tenantId filter.

Current workaround is to define all filters in single expression, or rewrite the expression to concat multiple filters.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions