Class QueryFilterAttribute
Declares a global query filter on an entity type or interface. The filter is applied to every query
in which the entity participates (the primary source, joins and subqueries) unless the query calls
IgnoreFilters. Multiple attributes are combined with and.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
public sealed class QueryFilterAttribute : Attribute
- Inheritance
-
QueryFilterAttribute
- Inherited Members
- Extension Methods
Remarks
A same-key attribute on a derived type replaces the one inherited from a base type (derived overrides base). Attributes are applied from the base type down to the most derived one. Two attributes that share a non-empty FilterKey on the same type are rejected when the metadata is built: the runtime does not guarantee attribute declaration order, so a repeated key on one type has no deterministic winner. Anonymous attributes (no key, or a whitespace key) are additive and may be repeated.
Properties
FilterFunc
The name of a static member of the attributed type that returns the builder-function form of the
filter as a Func<EntityBuilder<T>, IDataContext, EntityBuilder<T>>. The
member may be a field, a property or a parameterless method. The function is invoked once while
the plan is built and only the predicate it adds with Where is merged into the query; a
declaration must set either FilterLambda or FilterFunc, not both.
public string? FilterFunc { get; set; }
Property Value
FilterKey
The optional filter key. When omitted, empty or whitespace the filter is anonymous
(AnonymousKey); a key names the filter so it can be targeted by the
key-based IgnoreFilters. Repeating a key replaces the earlier filter; a keyed attribute
that sets neither FilterLambda nor FilterFunc removes the slot.
public string? FilterKey { get; set; }
Property Value
FilterLambda
The name of a static member of the attributed type that returns the filter lambda as an Expression<TDelegate> over the entity and, optionally, the IDataContext. The member may be a field, a property or a parameterless method.
public string? FilterLambda { get; set; }