public static FilterExpression CreateFilterExpression(CrmQuery crmQuery)
        {
            if (crmQuery == null)
                return null;

            FilterExpression filterExpression =
                new FilterExpression(OperatorMapper.GetMappedOperator(crmQuery.LogicalOperator));

            foreach (CrmAttributeCriterion condition in crmQuery.Conditions)
            {
                ConditionOperator conditionOperator = OperatorMapper.GetMappedOperator(condition.ConditionOperator);
                ConditionExpression conditionExpression = new ConditionExpression(condition.AttributeName, conditionOperator, condition.AttributeValue);
                filterExpression.AddCondition(conditionExpression);
            }
            return filterExpression;
        }
 /// <summary>
 /// Creates a FilterExpression from a CrmQuery object
 /// </summary>
 /// <param name="query">The query to which the FilterExpression should be added</param>
 /// <param name="crmQuery">The CrmQuery object</param>
 /// <returns>A FilterExpression</returns>
 public static void AddFilterExpression(QueryExpression query, CrmQuery crmQuery)
 {
     FilterExpression filterExpression = CreateFilterExpression(crmQuery);
     if (filterExpression != null)
         query.Criteria.AddFilter(CreateFilterExpression(crmQuery));
 }