Created
March 9, 2011 02:45
-
-
Save liammclennan/861595 to your computer and use it in GitHub Desktop.
proposed querying pattern
This file contains 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
// 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