Specifications
Structr.Specifications package provides .NET implementation of Specification pattern with set of simple operations with them.
Installation
Specifications package is available on NuGet.
Usage
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:
Method name | Description |
---|---|
| Creates specification which will be satisfied only when both specifications will be satisfied by provided instance of type |
| Creates specification which will be satisfied when at least one two specifications will be satisfied by provided instance of type |
| Creates specification which will be satisfied when given specification won't be satisfied by provided instance of type |
| Creates specification which will be satisfied when first specification will AND second will not be satisfied by provided instance of |
| Creates specification which will be satisfied when first specification will OR second will not be satisfied by provided instance of |
Additionally two predefined specifications are available:
Name | Description |
---|---|
| Specification to which all objects of |
| Specification to which none of objects of |
Entity Framework
Structr.Specifications may be helpful with Entity Framework 6 or Entity Framework Core. Use ToExpression()
method with Where()
for filtering entities in DbContext
:
Last updated