public void AddAttributes(List <string> attributeLogicalNames, List <string> propertiesToReturn)
        {
            // Attribute Query Properties - Which Properties to return
            AttributeQueryExpression attributeQuery = new AttributeQueryExpression();

            attributeQuery.Properties = new MetadataPropertiesExpression();
            attributeQuery.Properties.PropertyNames = propertiesToReturn;

            Request.Query.AttributeQuery = attributeQuery;

            // Attribute Query Criteria - Which Attributes to return
            MetadataFilterExpression critiera = new MetadataFilterExpression();

            attributeQuery.Criteria = critiera;
            critiera.FilterOperator = LogicalOperator.Or;
            critiera.Conditions     = new List <MetadataConditionExpression>();

            foreach (string attribute in attributeLogicalNames)
            {
                MetadataConditionExpression condition = new MetadataConditionExpression();
                condition.PropertyName      = "LogicalName";
                condition.ConditionOperator = MetadataConditionOperator.Equals;
                condition.Value             = attribute;
                critiera.Conditions.Add(condition);
            }
        }
 public static string SerialiseMetadataConditionExpression(MetadataConditionExpression item)
 {
     return(@"<c:MetadataConditionExpression>
                     <c:ConditionOperator>" + item.ConditionOperator.ToString() + @"</c:ConditionOperator>
                     <c:PropertyName>" + item.PropertyName + @"</c:PropertyName>
                     <c:Value i:type='d:string' xmlns:d='http://www.w3.org/2001/XMLSchema'>" + item.Value + @"</c:Value>
                   </c:MetadataConditionExpression>");
 }
        public void AddEntities(List <string> entityLogicalNames, List <string> propertiesToReturn)
        {
            Request.Query.Criteria = new MetadataFilterExpression();
            Request.Query.Criteria.FilterOperator = LogicalOperator.Or;
            Request.Query.Criteria.Conditions     = new List <MetadataConditionExpression>();

            foreach (string entity in entityLogicalNames)
            {
                MetadataConditionExpression condition = new MetadataConditionExpression();
                condition.ConditionOperator = MetadataConditionOperator.Equals;
                condition.PropertyName      = "LogicalName";
                condition.Value             = entity;
                Request.Query.Criteria.Conditions.Add(condition);
            }

            Request.Query.Properties = new MetadataPropertiesExpression();
            Request.Query.Properties.PropertyNames = propertiesToReturn;
        }