The QueryBuilder component has SyntaxProvider and MetadataProvider properties. This article describes the purpose of these objects and explains which one of available syntax and metadata providers you must choose.
Syntax Providers define the rules of SQL query parsing and generation for a particular database server. They also determine the queries to retrieve metadata from a particular database server using system tables. The component cannot work without a syntax provider. Also, there are few generic syntax providers for different ANSI SQL standards that can be used with any database server that's compatible with the appropriate standard.
You can use the AutoSyntaxProvider if you don't know to which database server the user will be connected. This syntax provider will send a series of server specific queries to detect the underlying database server. After successful detection it will act as appropriate database server syntax provider; otherwise, it will act as the Generic syntax provider.
The GenericSyntaxProvider is recommended to work with those database servers only for which Active Query Builder does not have an exclusive syntax provider. The Generic syntax provider supports only ANSI SQL/92 syntax and additionally implements the way to retrieve metadata from all the supported database servers. It was originally made for the Free Edition of Active Query Builder which lacks the support of today database server SQL syntax extensions.
Metadata Providers are intended to link Active Query Builder to specific data access components. Their primary task is to execute the metadata retrieval queries sent by the component. The Metadata provider does not create database connectivity objects, but an instance of appropriate database connection object should be assigned to the Connection property of the metadata provider.
The OLE DB, ODBC, and some other metadata providers also can retrieve metadata information using the GetSchema or other methods of appropriate data access components. If Active Query Builder fails to load metadata using the server-specific queries, it tries to load this information using metadata provider.
UniversalMetadataProvider is suitable for all types of database connections as it accepts System.Data.Common.DbConnection object which is a common ancestor of all .NET DB connections, but this provider not always the best choice as it lacks the support for specific DB connection ways to retrieve metadata. I recommend you to use it only if there's no specific metadata provider for your DB connection.
The EventMetadataProvider provides the way to get connected to DB connections that aren't inherited from the DbConnection object. It might be suitable for a three-tier connection or a web service.
The component can work without a metadata provider. In this case, it will not be able to execute the metadata retrieval queries. Thus this information must be loaded in some other ways and the QueryBuilder.OfflineMode property should be set to True to avoid run-time exceptions.
The following .NET C# code illustrates the common way of initializing metadata and syntax providers:
var connection = new <YourDbConnection>(); connection.ConnectionString = "your connection string here"; var syntaxProvider = new xxxSyntaxProvider(); var metadataProvider = new xxxMetadataProvider(); metadataProvider.Connection = connection; queryBuilder.SyntaxProvider = syntaxProvider; queryBuilder.MetadataProvider = metadataProvider;
Below is the list of supported DbConnection namespaces and appropriate metadata providers for Active Query Builder for .NET.