About the MetadataService

banner art

The Microsoft CRM SDK also contains the MetadataService Web service, which is used to access metadata. The metadata database contains the entity, attribute, and relationship definitions for your installation of Microsoft CRM, including your customizations.

This MetadataService Web service contains the methods you need to discover all of the entities in the system. It can also be used to build a client-side cache. This data is read-only, and there are no methods for manipulating the metadata. You must use the customization tools in the application to add, for example, entities, attributes, and customer forms. The MetadataService is optimized for performance, containing separate methods with various flags to limit the data retrieved from the server.

To use this Web Service you simply add the following Web Reference to your project:

https://<yourservername>/mscrmservices/2006/metadataservice.asmx

Example

The following code example shows the use of the MetadataService.

// Retrieve the metadata and build two arrays,
// one that contains core entities, the other custom entities.

MetadataService service = new MetadataService();
Metadata md = service.RetrieveMetadata(MetaDataFlags.Entities);
ArrayList coreEntities = new ArrayList();
ArrayList customEntities = new ArrayList();
foreach (EntityMetadata em in md.Entities)
{
   if (em.IsCustomEntity)
      customEntities.Add(em.Name);
   else
      coreEntities.Add(em.Name);
}

Related Topics

Accessing the Metadata

MetadataService

© 2007 Microsoft Corporation. All rights reserved.