HomeActive Query Builder - IntroductionDesigning user-friendly query building environmentModification of sub-queries independently of the main query

4.3. Modification of sub-queries independently of the main query

Now it is possible to modify the sub-query SQL text independently of the main query. The UnionSubQuery.SQL and SubQuery.SQL properties can be used to read and write the sub-query SQL text.

In addition to this feature we've made the option to filter the sub-query tabs in visual user interface in order to show only the sub-queries tabs that were used in the currently active sub-query. Another option is to let the PlainTextSQLBuilder retrieve the formatted text of the currently active sub-query. These options can be used independently, but supplement each other very well. Using both options the user will be able to view and edit the currently active sub-query as an independent query and easily get back to the main query when the editing is finished. Working in the sub-query editing mode, the programmer should assign the user edited query text to the PlainTextSQLBuilder.SQL property as it's always mapped to the active sub-query in this mode. And use the PlainTextSQLBuilder.SQLUpdated event to update the text editor as this event is fired not only when the query is changed in the Query Builder but also when the active sub-query is changed.

There are two variants of sub-query editing mode: editing single union sub-queries or editing sets of sub-queries with unions. I.e. if a sub-query contains unions, the user will edit each union sub-query independently in the first case and the whole set of union sub-queries in the second case. Thus the possible values of the PlainTextSQLBuilder.TargetQueryPart property that turn on this mode 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 QueryBuilder.FilterTabsByActiveQueryPart property with the same possible values instructs the component to filter sub-query tabs accordingly.

The "Show Query By Parts" demo project illustrates this functionality.

This page was: Helpful | Not Helpful