Specifications
Last updated
Was this helpful?
Last updated
Was this helpful?
Structr.Specifications package provides .NET implementation of with set of simple operations with them.
Specifications package is available on .
Main class of package - Specification<T>
- should be inherited by your own classes in order to use its functionality and extensions.
Example of basic usage:
Use specifications to filter models collection:
The whole list of Specification<T>
extensions is provided below:
And<T>
Creates specification which will be satisfied only when both specifications will be satisfied by provided instance of type T
.
Or<T>
Creates specification which will be satisfied when at least one two specifications will be satisfied by provided instance of type T
.
Not<T>
Creates specification which will be satisfied when given specification won't be satisfied by provided instance of type T
.
AndNot<T>
Creates specification which will be satisfied when first specification will AND second will not be satisfied by provided instance of T
.
OrNot<T>
Creates specification which will be satisfied when first specification will OR second will not be satisfied by provided instance of T
.
Additionally two predefined specifications are available:
AnySpecification<T>
Specification to which all objects of T
will match.
NoneSpecification<T>
Specification to which none of objects of T
will match.
Structr.Specifications may be helpful with or . Use ToExpression()
method with Where()
for filtering entities in DbContext
: