I'm trying to figure out a way to allow users of my application to define their own queries or filters that can be applied to a collection. I want to eventually provide an intuitive user interface to create these filters (see image below), but initial it would be OK if a user had to type of a text query string. I'll also need to be able to serialized these user defined queries to a string so I can save them with the rest of the project information.
Example UI
I'm looking for the type of functionality you would get out of something like a SQL query such as numeric conditions (less than, greater than), string condition (contains, starts with, ends with), or boolean condition (true or false). I'd also like to be able to group condition using boolean logic like OR, AND, and NOT.
I started drawing out how I would do this from scratch using classes such as NodeFilter, AbsNodeCondition, NodeStringCondition, NodeConditionOrJoin etc.. etc.. But I feel like I'm reinventing the wheel, especially when there's something like Linq available, which I haven't had a chance to spend much time with.
Could I somehow allow a user to enter a Linq to objects query in a text box, and then programaticly turn the string into a real Linq query that can be applied to my collection? Or is there some other way I could allow the user to create and save a query? I'll also need a way to serialize the filter/query to a string so I can save it with the rest of the program information.