Table of Contents

IT:AD:Patterns:Specification Pattern

Summary

Used extensively in App.Domain.Repositories.

It's separating the decision as to which object types should be selected in a query from the object that makes the selection.
Writing code like this allows reusing a Domain Layer Specification within a repository as a method for querying:

IEnumerable<Customer> customers = customerRepository.GetBySpec(IsPremiumCustomerSpecification);

That said, the original MF pattern was written prior to LINQ.

Considerations

[TODO]

Resources

* http://blog.willbeattie.net/2011/02/specification-pattern-entity-framework.html * http://nblumhardt.com/archives/implementing-the-specification-pattern-via-linq/ * http://guildsocial.web703.discountasp.net/dasblogce/2010/02/20/SpecificationPatternAndLinq.aspx * http://linqspecs.codeplex.com/