コード例 #1
0
 public override void Validate(FilterQueryOption filterQueryOption, ODataValidationSettings settings)
 {
     if (filterQueryOption.FilterClause.Expression.Kind == Microsoft.OData.UriParser.QueryNodeKind.BinaryOperator)
     {
         Microsoft.OData.UriParser.BinaryOperatorNode expr = filterQueryOption.FilterClause.Expression as Microsoft.OData.UriParser.BinaryOperatorNode;
         SingleValuePropertyAccessNode left = expr.Left as SingleValuePropertyAccessNode;
         if (left != null)
         {
             string propertyName = left.Property.Name;
             if (!ValidateFilterProperties(propertyName))
             {
                 throw new ODataException(string.Format("{0} cannot be used for filtering", propertyName));
             }
         }
     }
 }
コード例 #2
0
        private string BindBinaryOperatorNode(BinaryOperatorNode binaryOperatorNode)
        {
            var left = Bind(binaryOperatorNode.Left);
            var node = binaryOperatorNode.Left as SingleValueFunctionCallNode;

            if (node != null &&
                node.Name == "indexof")
            {
                return("(" + left + ")");
            }
            var right = Bind(binaryOperatorNode.Right);

            if (right != null && right.Trim() == " Null ".Trim() && (binaryOperatorNode.Right is ConvertNode))
            {
                if (((binaryOperatorNode.Right as ConvertNode).Source as ConstantNode).Value == null)
                {
                    return("(" + left + (binaryOperatorNode.OperatorKind == BinaryOperatorKind.Equal ? " Is " : " Is not ") + " " + right + ")");
                }
            }
            return("(" + left + " " + ToString(binaryOperatorNode.OperatorKind) + " " + right + ")");
        }