First, what is a repository?
…Therefore, use a Repository, the purpose of which is to
encapsulate all the logic needed to obtain object references. The
domain objects won’t have to deal with the infrastructure to get
the needed references to other objects of the domain. They will
just get them from the Repository and the model is regaining its
clarity and focus.
Excerpt from Domain Driven Design Quickly
So what the author is saying is that the repository’s (single) responsibility is to encapsulate the logic for obtaining object references. What that means to me is that the class utilizing the repository should be querying it in clear terms, such as:
_repository.GetPendingOrdersFor(customer);
This interface keeps the behavior of the method calling the repository focused on it’s job, and eliminates querying logic. Not only that, but the intention of the code is clear and even human(non-developer) readable.
The alternative is:
_respository.Query<Order>(o => o.CustomerID = customer.CustomerID && o.Status == OrderStatus.Pending);
Here’s how these options would look as an interface.
Just one man’s opinion. What do you think?