This is a discussion on pattern to pass/translate search parameters within the Software Patterns forums, part of the Testing category; I'm working on an application that requires some advanced search functionality and I'm looking for an extensible way ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
pattern to pass/translate search parameters
I'm working on an application that requires some advanced search
functionality and I'm looking for an extensible way to represent the search parameters, pass them from the view to the model, and translate them into something meaningful for the persistance layer. For example, if I have a "title" constraint, I want to be able to specify the value for title, pass it (along with an unlimited number of other constraints) to my data access layer, and it knows that it needs to append "where title = 'value'" to the search query. If I want a "time" constraint, the user can specify a start date and an end date, and I want to pass it, along with the "title" constraint, to the data access layer, and it knows to append "where title = 'value' and date > '2005-03-01' and date < '2005-04-20'". Originally I thought that the interpretor pattern might be a good way to solve this, even though that's not exactly what it is intended for, but the more I think about it, the less comfortable I am with that. Some suggested to me to try the command pattern, but I just don't see how that would work. Does anyone have any ideas for how to solve this? Thanks, Brandon |