Something is bothering me about repository pattern
What is the actual purpose of a repository ? I understand it as a part of Domain.Model, something that provides means of executing commands on aggregates and that is it.
Now if you are using a generic base Repository which provides means for CUD you might say that you're domain is not generic so the repository is not generic and I agree but only from one point of view the queries being emitted and not the commands.
I fell that a generic repository eliminates the need for Domain.Repositories at least in the context of DDD mixed with CQRS (I know that I might sound controversial and it's exactly how I fell as well). But if you split your commands from your queries, then you will have WriteRepositories containing only CUD operations. Thus having lots of duplicates all over the place.
Imagine this
CustomerRepository : ICustomerRepository
{
void Add(CustomerAggregate agg);
void Update(CustomerAggregate agg);
}
BookRepository : IBookRepository
{
void Add(BookAggregate agg);
}
SubscriptionsRepository : ISubscriptionsRepository
{
void Add(SubscriptionAggregate agg);
void Update(SubscriptionAggregate agg);
void Delete(SubscriptionAggregate agg);
}
...... another 5 repos
So does a generic repository makes sense in the context of DDD using CQRS pattern where you have Command.Stack + Query.Stack ?, and if so, does it eliminate the need for Domain.Repositories (command repositories) ?