Last active
December 25, 2015 02:09
-
-
Save benfoster/6900744 to your computer and use it in GitHub Desktop.
A better "repository" pattern.
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 IEntityStore | |
| { | |
| TEntity Get(Guid id) where TEntity : Entity | |
| IQueryable<TEntity> Query() where TEntity : Entity | |
| void Store<TEntity>(TEntity entity) where TEntity : Entity | |
| void Delete<TEntity>(Guid id) where TEntity : Entity | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're on the same page. I don;t know if you should feel guilty about queryable+predicates though - as long as you have a set of functional tests, you can refactor towards this approach with impunity if you feel the code is getting too messy.
I think its ok to create a ball of mud if you know you can polish it up later - one reason it's important to promote the approach here over the typical Repository.
(My preference for named delegates over the IUserQueries class is to avoid creating a class that ends up getting referenced all over the place, creating connections between namespaces. With standalone delegates you can keep them with the caller).