MetadataConditionExpression Class

Applies To: Microsoft Dynamics CRM 2013, Microsoft Dynamics CRM Online

Contains a condition expression used to filter the results of the metadata query.

Namespace: Microsoft.Xrm.Sdk.Metadata.Query
Assembly: Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)

Syntax

'Declaration
<DataContractAttribute(Name:="MetadataConditionExpression", Namespace:="https://schemas.microsoft.com/xrm/2011/Metadata/Query")> _
<KnownTypeAttribute("GetKnownConditionValueTypes")> _
Public NotInheritable Class MetadataConditionExpression
    Implements IExtensibleDataObject
[DataContractAttribute(Name="MetadataConditionExpression", Namespace="https://schemas.microsoft.com/xrm/2011/Metadata/Query")] 
[KnownTypeAttribute("GetKnownConditionValueTypes")] 
public sealed class MetadataConditionExpression : IExtensibleDataObject

Remarks

The following code snippet from Sample: Query Metadata and Detect Changes shows the use of MetadataConditionExpression to set conditions for Entities and Attributes to return.


     // An array SchemaName values for non-intersect, user-owned entities that should not be returned.
     String[] excludedEntities = {
"WorkflowLog",
"Template",
"CustomerOpportunityRole",
"Import",
"UserQueryVisualization",
"UserEntityInstanceData",
"ImportLog",
"RecurrenceRule",
"QuoteClose",
"UserForm",
"SharePointDocumentLocation",
"Queue",
"DuplicateRule",
"OpportunityClose",
"Workflow",
"RecurringAppointmentMaster",
"CustomerRelationship",
"Annotation",
"SharePointSite",
"ImportData",
"ImportFile",
"OrderClose",
"Contract",
"BulkOperation",
"CampaignResponse",
"Connection",
"Report",
"CampaignActivity",
"UserEntityUISettings",
"IncidentResolution",
"GoalRollupQuery",
"MailMergeTemplate",
"Campaign",
"PostFollow",
"ImportMap",
"Goal",
"AsyncOperation",
"ProcessSession",
"UserQuery",
"ActivityPointer",
"List",
"ServiceAppointment"};

     //A filter expression to limit entities returned to non-intersect, user-owned entities not found in the list of excluded entities.
     MetadataFilterExpression EntityFilter = new MetadataFilterExpression(LogicalOperator.And);
     EntityFilter.Conditions.Add(new MetadataConditionExpression("IsIntersect", MetadataConditionOperator.Equals, false));
     EntityFilter.Conditions.Add(new MetadataConditionExpression("OwnershipType", MetadataConditionOperator.Equals, OwnershipTypes.UserOwned));
     EntityFilter.Conditions.Add(new MetadataConditionExpression("SchemaName", MetadataConditionOperator.NotIn, excludedEntities));
     MetadataConditionExpression isVisibileInMobileTrue = new MetadataConditionExpression("IsVisibleInMobile", MetadataConditionOperator.Equals, true);
     EntityFilter.Conditions.Add(isVisibileInMobileTrue);
    

    ...
    

    
 //A condition expresson to return optionset attributes
 MetadataConditionExpression[] optionsetAttributeTypes = new MetadataConditionExpression[] { 
 new MetadataConditionExpression("AttributeType", MetadataConditionOperator.Equals, AttributeTypeCode.Picklist),
 new MetadataConditionExpression("AttributeType", MetadataConditionOperator.Equals, AttributeTypeCode.State),
 new MetadataConditionExpression("AttributeType", MetadataConditionOperator.Equals, AttributeTypeCode.Status),
 new MetadataConditionExpression("AttributeType", MetadataConditionOperator.Equals, AttributeTypeCode.Boolean)
 };

 //A filter expression to apply the optionsetAttributeTypes condition expression
 MetadataFilterExpression AttributeFilter = new MetadataFilterExpression(LogicalOperator.Or);
 AttributeFilter.Conditions.AddRange(optionsetAttributeTypes);

 //A Properties expression to limit the properties to be included with attributes
 MetadataPropertiesExpression AttributeProperties = new MetadataPropertiesExpression() { AllProperties = false };
 AttributeProperties.PropertyNames.Add("OptionSet");
 AttributeProperties.PropertyNames.Add("AttributeType");
    

    ...
    

    
 //An entity query expression to combine the filter expressions and property expressions for the query.
 EntityQueryExpression entityQueryExpression = new EntityQueryExpression()
 {

  Criteria = EntityFilter,
  Properties = EntityProperties,
  AttributeQuery = new AttributeQueryExpression()
  {
   Criteria = AttributeFilter,
   Properties = AttributeProperties
  },
  LabelQuery = labelQuery

 };
 
 //Retrieve the metadata for the query without a ClientVersionStamp
 RetrieveMetadataChangesResponse initialRequest = getMetadataChanges(entityQueryExpression, null, DeletedMetadataFilters.OptionSet);

Inheritance Hierarchy

System.Object
  Microsoft.Xrm.Sdk.Metadata.Query.MetadataConditionExpression

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Server 2008, Windows Server 2012, Windows 7 (All Versions), Windows 8 (All Versions)

Target Platforms

Windows 98,Windows 2000,Windows 2000 Server,Windows CE,Windows Server 2008,Windows 98 Second Edition,Pocket PC,Smart Phone,Windows Server 2003,Windows XP Professional,Windows Server 2008, ,Windows Server 2012, ,Windows 7 (All Versions), ,Windows 8 (All Versions)

Change History

See Also

Reference

MetadataConditionExpression Members
Microsoft.Xrm.Sdk.Metadata.Query Namespace

Other Resources

Query and Capture Changes to Metadata
Sample: Query Metadata and Detect Changes

Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.