What if it's not possible to provide direct access to a database for Active Query Builder?
There are several ways to cope with this task.
1. If it's possible to add some Active Query Builder assemblies to a location with direct access to a database, you can extract metadata using Active Query Builder API without creating a component itself.
You will need the ActiveQueryBuilder.Core and one of the ActiveQueryBuilder.*MetadataProvider assemblies for this. Create an SQLContext object, assign Syntax and Metadata Provider objects to appropriate properties, and use the SQLContext.MetadataContainer object to retrieve metadata using the LoadAll and ExportToXML methods.
using ActiveQueryBuilder.Core; using ActiveQueryBuilder.OLEDBMetadataProvdier; // create the right type of database connection obect var connection = new OleDbConnection(); connection.ConnectionString = "<your connection string here>"; // use the right type of Metadata and Syntax providers according to your database server and connection var metadataProvider = new OLEDBMetadataProvider(); metadataProvider.Connection = connection; var syntaxProvider = new MSSQLSyntaxProvider(); var context = new SQLContext(); context.MetadataProvider = metadataProvider; context.SyntaxProvider = syntaxProvider; context.MetadataContainer.LoadAll(true); // with or without fields context.MetadataContainer.ExportToXML("metadata.xml"); // to file or to stream
2. Create the XML file with your metadata manually and pass it to Active Query Builder. The XSD schema is available here.
3. Pass information about metadata in any format, then use the Active Query Builder API to fill the Metadata Container programmatically as described in this article:
How to add objects to the Metadata Container programmatically?