Created
May 17, 2011 03:30
-
-
Save jmarnold/975884 to your computer and use it in GitHub Desktop.
Specifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ISpecification<T> | |
{ | |
Expression<Func<T, bool>> IsSatisfied(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual IQueryable<T> Query(ISpecification<T> query) | |
{ | |
var specifications = _specificationPolicies | |
.Where(p => p.Applies<T>()) | |
.Select(p => p.Build<T>()) | |
.ToList(); | |
specifications.Add(query); | |
var specification = _specificationComposer.Compose(specifications); | |
return Entities.Where(specification.IsSatisfied()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment