Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AttributeQueryExpression Class

Defines a complex query to retrieve attribute metadata for entities retrieved using an EntityQueryExpression

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

[DataContractAttribute(Name="AttributeQueryExpression", Namespace="http://schemas.microsoft.com/xrm/2011/Metadata/Query")] 
public sealed class AttributeQueryExpression : MetadataQueryExpression

The following example shows the use of an AttributeQueryExpression to retrieve entity metadata.

//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);

//A Properties expression to limit the properties to be included with attributes
MetadataPropertiesExpression AttributeProperties = new MetadataPropertiesExpression() { AllProperties = false };
//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);

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

Development Platforms

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

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,Windows 8,Windows 8.1

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

Community Additions

© 2015 Microsoft