Table of Contents

Class QueryFilters

Namespace
eQuantic.Core.Data.Repository
Assembly
eQuantic.Core.Data.dll

The global query filters — predicates a provider ANDs into every read (and set-based write) of an entity type, the way EF Core's HasQueryFilter scopes multi-tenant data, soft deletes or row-level visibility. Register one instance as a singleton (services.AddSingleton(new QueryFilters().For<Order>(...))); the unit of work picks it up from its scope's service provider. A filter can be a fixed predicate or a per-request factory that receives the scoped IServiceProvider — resolve the current tenant (or user, or feature flag) there and return the predicate for this request. A query opts out with IgnoringQueryFilters(); set-based writes never opt out (a tenant-scoped delete stays tenant-scoped).

public sealed class QueryFilters
Inheritance
QueryFilters
Inherited Members

Methods

FilterFor(Type, IServiceProvider)

Resolves the global filter for entityType in the given scope, or null when none applies — the runtime-typed path multi-entity reads (union branches) resolve per branch.

public LambdaExpression? FilterFor(Type entityType, IServiceProvider services)

Parameters

entityType Type

The entity type.

services IServiceProvider

The scope's service provider (handed to per-request factories).

Returns

LambdaExpression

FilterFor<TEntity>(IServiceProvider)

Resolves the global filter for TEntity in the given scope, or null when none applies.

public Expression<Func<TEntity, bool>>? FilterFor<TEntity>(IServiceProvider services) where TEntity : class

Parameters

services IServiceProvider

The scope's service provider (handed to per-request factories).

Returns

Expression<Func<TEntity, bool>>

Type Parameters

TEntity

The entity type.

For<TEntity>(Func<IServiceProvider, Expression<Func<TEntity, bool>>?>)

Registers a per-request global filter for TEntity: the factory runs on every query with the scope's service provider — resolve the current tenant there. Returning null applies no filter for that request.

public QueryFilters For<TEntity>(Func<IServiceProvider, Expression<Func<TEntity, bool>>?> filter) where TEntity : class

Parameters

filter Func<IServiceProvider, Expression<Func<TEntity, bool>>>

The per-request predicate factory.

Returns

QueryFilters

The same instance for chaining.

Type Parameters

TEntity

The entity type.

For<TEntity>(Expression<Func<TEntity, bool>>)

Registers a fixed global filter for TEntity.

public QueryFilters For<TEntity>(Expression<Func<TEntity, bool>> filter) where TEntity : class

Parameters

filter Expression<Func<TEntity, bool>>

The predicate ANDed into every query of the entity.

Returns

QueryFilters

The same instance for chaining.

Type Parameters

TEntity

The entity type.