AttributeQueryExpression Class

 

Applies To: Dynamics CRM 2015

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)

Inheritance Hierarchy

System.Object
  Microsoft.Xrm.Sdk.Metadata.Query.MetadataQueryBase
    Microsoft.Xrm.Sdk.Metadata.Query.MetadataQueryExpression
      Microsoft.Xrm.Sdk.Metadata.Query.AttributeQueryExpression

Syntax

[DataContractAttribute(Name = "AttributeQueryExpression", Namespace = "https://schemas.microsoft.com/xrm/2011/Metadata/Query")]
public sealed class AttributeQueryExpression : MetadataQueryExpression
[DataContractAttribute(Name = "AttributeQueryExpression", Namespace = "https://schemas.microsoft.com/xrm/2011/Metadata/Query")]
public ref class AttributeQueryExpression sealed : MetadataQueryExpression
[<Sealed>]
[<DataContractAttribute(Name = "AttributeQueryExpression", Namespace = "https://schemas.microsoft.com/xrm/2011/Metadata/Query")>]
type AttributeQueryExpression = 
    class
        inherit MetadataQueryExpression
    end
<DataContractAttribute(Name := "AttributeQueryExpression", Namespace := "https://schemas.microsoft.com/xrm/2011/Metadata/Query")>
Public NotInheritable Class AttributeQueryExpression
    Inherits MetadataQueryExpression

Constructors

Name Description
System_CAPS_pubmethod AttributeQueryExpression()

Initializes a new instance of the AttributeQueryExpression class.

Properties

Name Description
System_CAPS_pubproperty Criteria

Gets or sets the filter criteria for the metadata query.(Inherited from MetadataQueryExpression.)

System_CAPS_pubproperty ExtensionData

Gets or sets the structure that contains extra data.(Inherited from MetadataQueryBase.)

System_CAPS_pubproperty Properties

Gets or sets the properties to be returned by the query.(Inherited from MetadataQueryExpression.)

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

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

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.

See Also

Microsoft.Xrm.Sdk.Metadata.Query Namespace
Retrieve and detect changes to metadata
Sample: Query metadata and detect changes

Return to top

© 2016 Microsoft. All rights reserved. Copyright