Skip to content

Instantly share code, notes, and snippets.

@liammclennan
Created March 9, 2011 02:45
Show Gist options
  • Save liammclennan/861595 to your computer and use it in GitHub Desktop.
Save liammclennan/861595 to your computer and use it in GitHub Desktop.
proposed querying pattern
// setup a specification
var specification = new UserWithClientSpecification(userId);
var userWithClient = userService.RetrieveWithSpecification(specification);
// and the specification class would be...
public class UserWithClientSpecification : ISpecification<User>
{
public UserWithClientSpecification(int userId)
{
this.userId = userId;
}
public IList<User> Filter(IQueryable<User> users)
{
return users.Where(u => u.UserId == userId);
}
public string EagerLoad()
{
return "Client";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment