Compartilhar via


RetrieveMetadataChangesRequest Class

Definition

Contains the data that is needed to retrieve a collection of EntityMetadata records that satisfy the specified criteria.

The RetrieveMetadataChangesResponse returns a ServerVersionStamp value that can be used with this request at a later time to return information about how schema definitions have changed since the last request.

public ref class RetrieveMetadataChangesRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class RetrieveMetadataChangesRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type RetrieveMetadataChangesRequest = class
    inherit OrganizationRequest
Public NotInheritable Class RetrieveMetadataChangesRequest
Inherits OrganizationRequest
Inheritance
RetrieveMetadataChangesRequest
Attributes

Examples

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface instance.

/// <summary>
/// Get the SchemaName for the account and contact tables together with
/// the LogicalName of any columns that are valid for create
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void SimpleRetrieveMetadataChangesExample(IOrganizationService service) {

    var query = new EntityQueryExpression
    {
        Properties = new MetadataPropertiesExpression("SchemaName", "Attributes"),
        Criteria = new MetadataFilterExpression(filterOperator: LogicalOperator.Or)
        {
            Conditions = {
                {
                    new MetadataConditionExpression(
                        propertyName:"LogicalName",
                        conditionOperator: MetadataConditionOperator.Equals,
                        value:"account")
                },
                {
                    new MetadataConditionExpression(
                        propertyName:"LogicalName",
                        conditionOperator: MetadataConditionOperator.Equals,
                        value:"contact")
                }
            }, 
        },
        AttributeQuery = new AttributeQueryExpression
        {
            Properties = new MetadataPropertiesExpression("LogicalName"),
            Criteria = new MetadataFilterExpression(filterOperator: LogicalOperator.And)
            {
                Conditions = {
                    {
                        new MetadataConditionExpression(
                        propertyName:"IsValidForCreate",
                        conditionOperator: MetadataConditionOperator.Equals,
                        value:true)
                    }
                }
            }            
        },
        LabelQuery = new LabelQueryExpression { 
              FilterLanguages = {
                { 1033 }
            } 
        }        
    };

    var request = new RetrieveMetadataChangesRequest
    {
        Query = query
    };

    var response = (RetrieveMetadataChangesResponse)service.Execute(request);

    response.EntityMetadata.ToList().ForEach(em => {

        Console.WriteLine($"Entity SchemaName:{em.SchemaName}");
        em.Attributes.ToList().ForEach(a => {
            Console.WriteLine($"\tAttribute LogicalName:{a.LogicalName}");
        });
    });
}

Output:

Entity SchemaName:Account
      Attribute LogicalName:emailaddress3
      Attribute LogicalName:emailaddress1
      Attribute LogicalName:address1_city
<List truncated for brevity>
Entity SchemaName:Contact
      Attribute LogicalName:contactid
      Attribute LogicalName:emailaddress3
      Attribute LogicalName:emailaddress2
<List truncated for brevity>

Sample code on GitHub

RetrieveMetadataChanges Sample

Remarks

Usage

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of RetrieveMetadataChangesResponse.

Notes for Callers

This message provides two capabilities:

  • Query: Compose a single query to retrieve just the schema data you need. Learn how to query schema definitions.

  • Cache Management: Caching may result in a significant improvement time for your application to start. If you cache the schema definition data with your app, you can use RetrieveMetadataChanges to efficiently retrieve only the changes since your last query. Use the information about these changes to add or remove items in your cache. Learn how to cache schema data.

Constructors

RetrieveMetadataChangesRequest()

Initializes a new instance of the RetrieveMetadataChangesRequest class.

Properties

ClientVersionStamp

Gets or sets a timestamp value representing when the last request was made.

DeletedMetadataFilters

Gets or sets a value to filter what deleted metadata items will be returned.

ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
Query

Gets or sets the query representing the metadata to return.

RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RetrieveAllSettings

For internal use only.

Applies to