/// <summary> /// Converts a normalized binary expression into the appropriate ParseQuery clause. /// </summary> private static ParseQuery <T> WhereBinaryExpression <T>( this ParseQuery <T> source, Expression <Func <T, bool> > expression, BinaryExpression node) where T : ParseObject { var leftTransformed = new ObjectNormalizer().Visit(node.Left) as MethodCallExpression; if (!(IsParseObjectGet(leftTransformed) && leftTransformed.Object == expression.Parameters[0])) { throw new InvalidOperationException( "Where expressions must have one side be a field operation on a ParseObject."); } var fieldPath = GetValue(leftTransformed.Arguments[0]) as string; var filterValue = GetValue(node.Right); if (filterValue != null && !ParseEncoder.IsValidType(filterValue)) { throw new InvalidOperationException( "Where clauses must use types compatible with ParseObjects."); } switch (node.NodeType) { case ExpressionType.GreaterThan: return(source.WhereGreaterThan(fieldPath, filterValue)); case ExpressionType.GreaterThanOrEqual: return(source.WhereGreaterThanOrEqualTo(fieldPath, filterValue)); case ExpressionType.LessThan: return(source.WhereLessThan(fieldPath, filterValue)); case ExpressionType.LessThanOrEqual: return(source.WhereLessThanOrEqualTo(fieldPath, filterValue)); case ExpressionType.Equal: return(source.WhereEqualTo(fieldPath, filterValue)); case ExpressionType.NotEqual: return(source.WhereNotEqualTo(fieldPath, filterValue)); default: throw new InvalidOperationException( "Where expressions do not support this operator."); } }