Robotico.Specification 1.0.2
Robotico.Specification
Specification pattern for .NET 8 and .NET 10. Composable query criteria as objects: ISpecification<T>, And, Or, Not. Use with repositories and EF Core. Zero dependencies.
Pattern
Reference Robotico.Specification when you use the Specification pattern: reusable, composable query criteria instead of ad-hoc predicates.
Features
- ISpecification
: IsSatisfiedBy(T candidate), optionalToExpression()for EF Core - Composition: And, Or, Not specifications
- Zero dependencies: no EF or other packages required
Installation
dotnet add package Robotico.Specification
Quick start
using Robotico.Specification;
// Define a specification
public sealed class ActiveUsersSpec : ISpecification<User>
{
public bool IsSatisfiedBy(User candidate) => candidate.IsActive;
public System.Linq.Expressions.Expression<Func<User, bool>>? ToExpression() => u => u.IsActive;
}
// Compose
var spec = new ActiveUsersSpec().And(new VerifiedEmailSpec());
bool ok = spec.IsSatisfiedBy(user);
License
See repository license file.
No packages depend on Robotico.Specification.
.NET 8.0
- Robotico.Domain (>= 1.0.2)
- Robotico.Option (>= 1.0.2)
.NET 10.0
- Robotico.Domain (>= 1.0.2)
- Robotico.Option (>= 1.0.2)