FluentSpecification.Core
contains first of all, remained implementation of Specification design pattern.
Here you can find Specifications for composition (And, Or) and special extensions for Fluent API. Library also contains Specification for negation,
with special validation handling (error message negation) and negation of Linq expressions.
Most of Specifications use abstract implementation of validation and Linq Specifications, placed in Core package.
At the end package has bunch of utils and extensions, useful in validation scenarios and in Linq expressions composing.
List of available built-in Specifications.
Everything is Complex
As described in previous section there is IComplexSpecification<T>
interface,
aggregation of ISpecification<T>
, IValidationSpecification<T>
and ILinqSpecification<T>
interfaces. Every built-in Specification implements IComplexSpecification<T>
interface.
And, Or, and Not Specifications are also "complex", but as input they take "normal" ISpecification<T>
. Inside, input Specification is converted by special extension method - AsComplexSpecification
.
All Specifications, that do not implement IComplexSpecification<T>
interface, are adapted by internal SpecificationAdapter<T>
.
This Adapter implements IComplexSpecification<T>
interface and invokes proper methods from Base Specification.
For example if Base Specification not implement Linq interface, Adapter invokes IsSatisfiedBy
method in Lambda expression.
If Base Specification has GetExpression
, Adapter gets this expression from base.
Other methods are processed similarly (also from Negatable interfaces).
SpecificationAdapter<T>
is internal class, but AsComplexSpecification
is public extension for every Specification.
BE AWARE! Linq expressions produced in this way, will not work with LinqToEntities (Ef 6
scenarios). In EF Core
should works fine.
For EF 6
, ILinqSpecification<T>
implementation with special expressions building is necessary.