I get a list of items from my Repository. Now I need to sort and filter them, which I believe would be done in the Repository for efficiency. I think there would be two ways of doing this in a DDD way:
- Send a filter and a sort object full of conditions to the Repository (What is this called)?
- Repository result would produce an object with .filter and .sort methods? (This wouldn't be a POJO/POCO because it contains more than one object?).
So is the answer 1, 2, or other? Could you explain why? I am leaning toward #1 because the Repository would be able to only send the data I want (or will #2 be able to delay accessing data like a LazyList?) A code example (or website link) would be very helpful.
Example:
- Product product = repo.GetProducts(mySortObject, myFilterObject); // List of Poco
- product.AddFilter("price", "lessThan", "3.99"); product.AddSort("price", "descending");