I'm working on an experimental TreeView where each TreeViewItem can either represent a condition, or a branch with an operator. This is to be parsed into SQL.
For example, the tree could have a branch with an "AND" or an "OR" operator, whose children would then be conditions. This is used to as to be able to generate the WHERE
segment of an SQL statement, for example ((Name = 'Matt' AND AGE > 20) OR (Name = 'John' AND Age = 15)) AND Job = 'Student'
.
How can I go about constructing that? What I've done so far is thought about placing a string,list<Condition>
pair in a Tuple<>
, where the string represents the branch operator (AND/OR), and the list represents the conditions contained within that branch.
However, since each branch can be split into a number of operator branches or conditions, it can get extremely complicated very quickly