Supporting ad-hoc queries in a multi-tiered application
-
15-11-2019 - |
Question
Is there a standard design pattern or approach that will support ad hoc queries in a multi-tiered application?
Some motivation for this question: In my current project, we are using the IRepository<> pattern extensively in the middle tier. The version of IRepository<> that we're using has a FilterBy() method that takes in an Expression<> in an attempt to support arbitrary queries. But if the Expression<> is composed (say) at the ViewModel level, it will be expressed in terms of DTOs (Data Transfer Objects)....
How do we avoid either exposing the UI to database-specific details or doing a "GetAll()" at the database level, wrapping everything as it passes up through the layers, only to discard 90% of it at the DTO/ViewModel layer?
Thanks, Jim
Solution
This question is answered by a separate post: Generic vs. Specialized Repositories