Active Query Builder support area

Getting started with AQB.NET 3 in the Separated Controls UI or Non-visual mode

Last modified:

This article describes the advanced way of setting up the component. It is more complicated but provides a much higher level of freedom in organizing the user interface. It is available in the Professional subscription only.

We recommend getting started with the simple Quick Start Guide for AQB.NET 3 before reading this article.
This article provides more details about the architecture of Active Query Builder 3.


Lots of demo projects illustrating various aspects of the functionality and different usage scenarios are shipped within the trial installation package. They can also be downloaded from the Active Query Builder 3 .NET Examples GitHub repositories.


The internal query objects structure

After Active Query Builder parses a query, it becomes available for the programmer in two ways: low-level representation in the form of tokens tree. (We call this level "AST": abstract syntax tree. The high-level object structure consists of sub-queries, datasources, output query columns, etc. The top-level object structure internally holds the low-level representation. The object form is available via the SQLQuery.QueryRoot reference.

The high-level query object form is a tree-like structure of sub-queries (unions, derived tables, common table expressions). It starts with the Query object of SubQuery class that has the SubQueries indexed property holding nested sub-queries. A SubQuery may consist of several SELECT statements joined with the UNION, EXCEPT or INTERSECT keywords. Thus the SubQuery class is a collection of single SELECT queries, containing at least one item. The UnionSubQuery object represents a single SELECT query.

The non-visual components

The SQLQuery object is a query building logic controller that provides the necessary means to operate with the query objects, and that's the object to which visual controls refer to perform manipulations with query objects. The internal query objects structure can be accessed via the SQLQuery.QueryRoot property.

The SQLQuery object must be created in a context of specific SQL syntax rules and connection to a database. The SQLContext object is responsible for holding the definition of these things. It refers to metadata and syntax providers and contains the MetadataContainer and MetadataStructure objects to store information about database schema, and it's visual presentation in a tree-like form.

The visual controls

The Active Query Builder user interface has the QueryNavigationBar control to deal with the tree-like structure of sub-queries. Visual controls for editing of single SELECT query parts, such as the DesignPaneControl and the QueryColumnsListControl, must be placed inside the QueryView panel that holds a reference to the currently active union sub-query (QueryView.ActiveUnionSubQuery). The Query Navigation Bar refers to the QueryView object to change the currently visible sub-query.

Source code sample

Below is the source code of initialization of Active Query Builder components that will help you to link them with each other.

// Non-visual objects
_sqlContext = new SQLContext
    SyntaxProvider = new MSSQLSyntaxProvider {ServerVersion = MSSQLServerVersion.MSSQL2012},
    MetadataProvider = new OLEDBMetadataProvider 
        Connection = new OleDbConnection() {ConnectionString = "<Your connection string here>"}

_sqlQuery = new SQLQuery(_sqlContext);

// Visual controls
queryView1.Query = _sqlQuery;

navBar1.Query = _sqlQuery;
navBar1.QueryView = queryView1;

databaseSchemaView1.SQLContext = _sqlContext;
databaseSchemaView1.QueryView = queryView1;

// Linking visual query builder with text editor
sqlTextEditor.QueryProvider = _sqlQuery;
_sqlQuery.SQLUpdated += sqlQuery_SQLUpdated;

// Initialization
_sqlQuery.SQL = "SELECT * FROM dbo.Customers";


Customizable layout of user interface controls

The Dock Manager control lets hold any controls to the left, right or beneath its workspace as hideable panels.

The code samples of the programmatic addition of sidebar panels to the DockManager control can be found here: WinForms, WPF.

Objects diagram

This diagram can help you to find the needed objects to work with Active Query Builder in non-visual mode, or to build the custom combination of visual controls, or may be to create your visual controls to deal with specific parts of the query and add them to Active Query Builder UI.

Architecture of Active Query Builder 3 - separated controls mode 

Learn more



Is this article helpful for you?