HomeActive Query Builder - Metadata handling and filtrationWorking with metadata in .NET versionLoading, finding and removing objects from the Metadata Container

1.5. Loading, finding and removing objects from the Metadata Container

To load all objects from the database schema to the Metadata Container (taking into account limitations specified by Metadata Filters), use the MetadataContainer.LoadAll method. The withFields parameter instructs whether to load fields for objects or not. Fields loading is the longest operation (separate query is executed for every database object), so the LoadAll(true) call might work very long on large databases. If you fill the metadata container with objects without fields, the fields will be loaded on demand when you add an object to a query.

Metadata Container is a tree-like structure, that groups objects by namespaces in a tree-like structure (servers, databases, schemas, packages - each level can be omitted if it's not applicable to specific database server). To load only one level of this hierarchy, or objects of specifiс type, use the MetadataItem.Items.Load method. For example the MetadataContainer.Items.Load(Database|Schema, true) call will load all database and schema levels of the metadata container.

The other methods allow to iterate items that are already loaded into the MetadataContainer.

  • The MetadataList.Find* methods find and return matching metadata items or their indices (without loading them from database).
  • The MetadataList.GetItems and MetadataList.GetItemsRecursive methods return items from the list (and child items lists) without loading them from database.
  • The MetadataItem.Find* methods recursively load items of child hierarchy from database, and rerurn matching ones.
  • The MetadataStructure.GetAllMetadataItems method loads and returns all metadata items that might be visible in the Database Schema Tree (according to the current Metadata Structure).

To remove an object from the Metadata Conainer, you should remove it from the list of parent metadata items:

    metadataItem.Parent.Items.Remove(metadataItem);

This page was: Helpful | Not Helpful