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