Home → Active Query Builder - Metadata handling and filtration → Working with metadata in .NET version → Description of the Metadata Container
1.1. Description of the Metadata Container
Metadata Container was reorganized from the plain list of objects to the hierarchical structure. There are three types of elements of this structure: namespaces, objects and sub-object items.
Namespaces reflect object grouping in the database server. They can represent linked servers, databases, schemas and packages. Objects can be tables, views, synonyms, stored procedures or functions (only those procedures and functions that return dataset and can be used as data sources in the SELECT queries). Currently the component deals with three types of sub-object items: fields, parameters and foreign keys, as these types of items are needed by the component to build queries and to represent them visually.
Metadata Container loads metadata from the database by demand. This happens when the user expands a node of the Database Schema Tree, when database object is added to the query and when the component associates objects in the parsed query with objects in the database.
Metadata Container loads objects from the current database (according to the connection settings) by default and hides objects from other databases and linked servers. If you want to show all available databases as well as from linked servers (if any), you can set the QueryBuilder.MetadataLoadingOptions.LoadDefaultDatabaseOnly property to false. If you want to show metadata from specific databases or linked servers only or you want to limit the schemas visible to the end-user, you can instruct the component to do this using a few simple calls that described in this article. Fine-tuning adjustment of the object's visibility can be achieved by means of the Metadata Structure or Metadata Filters. Also you can add the necessary objects programmatically.
MetadataItem is the base type for all metadata items. The following classes are derived from it: MetadataContainer, MetadataNamespace, MetadataObject, MetadataField, MetadataParameter and MetadataForeignKey. The exact type of MetadataNamespace and MetadataObject is determined by the Type property.
MetadataContainer is the root node of the tree. It stores the MetadataLoadingOptions, has the OfflineMode property, provides methods to save and load metadata to XML format and events to handle items loading.
Metadata Container (as well as any other metadata item) can be forced to load all child items with the LoadAll method. It has the withFields parameter that determines whether to load fields or not as loading fields may take a long time in case of large database schema.
Metadata Container has the necessary methods (Find*) to find objects and to load them if they aren't loaded yet in the child items hierarchy. If you want to make searching over the loaded items only, you can get the list of loaded items of specific type using the Items.Find*, Items.GetItems and Items.GetItemsRecursive methods.
The ItemMetadataLoading and ItemMetadataLoaded events of the MetadataContainer allows to perform pre- and post-processing when child metadata items are requested to load from the database. For example, you can override loading of fields or foreign keys for database objects or change their properties when loading is finished. You may find sample handlers of these events here.