Active Query Builder lets modify the text of sub-query independently of the main query. The UnionSubQuery.SQL and SubQuery.SQL properties can be used to read and write sub-query SQL text.
When working in the sub-query editing mode, the programmer must assign the user edited query text to the PlainTextSQLBuilder.SQL property as it's always mapped to the active sub-query. He must use the PlainTextSQLBuilder.SQLUpdated event to update the text editor as this event is fired not only on changing of the query in the Query Builder but also on switching of the active sub-query.
Another option is to let the PlainTextSQLBuilder retrieve the formatted text of the currently active sub-query. In this mode, the user sees and edits the currently active sub-query as an independent query. He can easily get back from this mode when needed.
There are two variants of sub-query editing mode: editing single union sub-queries or editing sets of sub-queries with unions. In other words, if a subquery contains unions, the user can separately edit each union sub-query, or he can modify the whole set of union sub-queries.
Below are the possible values of the PlainTextSQLBuilder.TargetQueryPart property that turns this mode on are the following:
- Query (default) – instructs to generate SQL text for the whole query;
- SubQuery – instructs to generate SQL text for the currently active sub-query with unions;
- UnionSubQuery – instructs to generate SQL text for the currently active union sub-query.
The "SubQuery Text Editing" demo project illustrates this functionality.