Skip to content

Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.

Learn more about Software Architecture & Design.
Join thousands of developers getting weekly updates to increase your understanding of software architecture and design concepts.


Follow @CodeOpinion

CQRS

Query Objects instead of Repositories

The repository pattern is often used to encapsulate simple and sometimes rather complex query logic.   However, it has also been morphed into handling persistence and is often used as another layer of abstraction from your data mapping layer.   This blog post show you how to slim down and simplify your repositories or possibly eliminate them all together by using query objects. A typical repository will look something like this: public interface IProductRepository { void Insert(Product product); void Delete(Product product); IEnumerable<Product> GetById(Guid id); IEnumerable<Product> GetAllActive(); IEnumerable<Product> FindByName(string name); IEnumerable<Product> FindBySku(string name); IEnumerable<Product> Find(string keyword, int limit, int page); IEnumerable<Product> GetRelated(Guid id); } Each… Read More »Query Objects instead of Repositories