Building specifications
A specification is a named, reusable, combinable, and testable class to filter domain objects based on business rules. In practice, we can easily encapsulate filter expressions as reusable objects.
In this section, we will begin with the most simple, parameterless specifications. We will then see more complex, parameterized specifications. Finally, we will learn how to combine multiple specifications to create a more complex specification.
Parameterless specifications
Let's begin with a very simple specification class:
public class OnlineEventSpecification : Specification<Event> { public override Expression<Func<Event, bool>> ToExpression() { return x => x.IsOnline == true; } }
OnlineEventSpecification
is used to filter online events...