Example #1
0
        /// <summary>
        /// Creates a <see cref="FilterClause"/>.
        /// </summary>
        /// <param name="expression">The filter expression - this should evaluate to a single boolean value. Cannot be null.</param>
        /// <param name="rangeVariable">The parameter for the expression which represents a single value from the collection. Cannot be null.</param>
        /// <exception cref="System.ArgumentNullException">Throws if the input expression or rangeVariable is null.</exception>
        public FilterClause(SingleValueNode expression, RangeVariable rangeVariable)
        {
            ExceptionUtils.CheckArgumentNotNull(expression, "expression");
            ExceptionUtils.CheckArgumentNotNull(rangeVariable, "parameter");

            this.expression    = expression;
            this.rangeVariable = rangeVariable;
        }
Example #2
0
        /// <summary>
        /// Creates a <see cref="FilterClause"/>.
        /// </summary>
        /// <param name="expression">The filter expression - this should evaluate to a single boolean value. Cannot be null.</param>
        /// <param name="rangeVariable">The parameter for the expression which represents a single value from the collection. Cannot be null.</param>
        /// <exception cref="System.ArgumentNullException">Throws if the input expression or rangeVariable is null.</exception>
        public FilterClause(SingleValueNode expression, RangeVariable rangeVariable)
        {
            ExceptionUtils.CheckArgumentNotNull(expression, "expression");
            ExceptionUtils.CheckArgumentNotNull(rangeVariable, "parameter");

            this.expression = expression;
            this.rangeVariable = rangeVariable;
        }
Example #3
0
        /// <summary>
        /// Creates an <see cref="OrderByClause"/>.
        /// </summary>
        /// <param name="thenBy">The next orderby to perform after performing this orderby, can be null in the case of only a single orderby expression.</param>
        /// <param name="expression">The order-by expression. Cannot be null.</param>
        /// <param name="direction">The direction to order.</param>
        /// <param name="rangeVariable">The rangeVariable for the expression which represents a single value from the collection we iterate over. </param>
        /// <exception cref="System.ArgumentNullException">Throws if the input expression or rangeVariable is null.</exception>
        public OrderByClause(OrderByClause thenBy, SingleValueNode expression, OrderByDirection direction, RangeVariable rangeVariable)
        {
            ExceptionUtils.CheckArgumentNotNull(expression, "expression");
            ExceptionUtils.CheckArgumentNotNull(rangeVariable, "parameter");

            this.thenBy        = thenBy;
            this.expression    = expression;
            this.direction     = direction;
            this.rangeVariable = rangeVariable;
        }
Example #4
0
        /// <summary>
        /// Creates an <see cref="OrderByClause"/>.
        /// </summary>
        /// <param name="thenBy">The next orderby to perform after performing this orderby, can be null in the case of only a single orderby expression.</param>
        /// <param name="expression">The order-by expression. Cannot be null.</param>
        /// <param name="direction">The direction to order.</param>
        /// <param name="rangeVariable">The rangeVariable for the expression which represents a single value from the collection we iterate over. </param>
        /// <exception cref="System.ArgumentNullException">Throws if the input expression or rangeVariable is null.</exception>
        public OrderByClause(OrderByClause thenBy, SingleValueNode expression, OrderByDirection direction, RangeVariable rangeVariable)
        {
            ExceptionUtils.CheckArgumentNotNull(expression, "expression");
            ExceptionUtils.CheckArgumentNotNull(rangeVariable, "parameter");

            this.thenBy = thenBy;
            this.expression = expression;
            this.direction = direction;
            this.rangeVariable = rangeVariable;
        }
Example #5
0
 /// <summary>
 /// Creates a RangeVariableReferenceNode for a given range variable
 /// </summary>
 /// <param name="rangeVariable">Name of the rangeVariable.</param>
 /// <returns>A new SingleValueNode (either an Entity or NonEntity RangeVariableReferenceNode.</returns>
 internal static SingleValueNode CreateRangeVariableReferenceNode(RangeVariable rangeVariable)
 {
     if (rangeVariable.Kind == RangeVariableKind.Nonentity)
     {
         return new NonentityRangeVariableReferenceNode(rangeVariable.Name, (NonentityRangeVariable)rangeVariable);
     }
     else
     {
         EntityRangeVariable entityRangeVariable = (EntityRangeVariable)rangeVariable;
         return new EntityRangeVariableReferenceNode(entityRangeVariable.Name, entityRangeVariable);
     }
 }
Example #6
0
 /// <summary>
 /// Create a LambdaNode
 /// </summary>
 /// <param name="rangeVariables">The collection of rangeVariables in scope for this Any or All.</param>
 /// <param name="currentRangeVariable">The newest range variable added for by this Any or All.</param>
 protected LambdaNode(Collection <RangeVariable> rangeVariables, RangeVariable currentRangeVariable)
 {
     this.rangeVariables       = rangeVariables;
     this.currentRangeVariable = currentRangeVariable;
 }
 public override void ValidateRangeVariable(RangeVariable rangeVariable, ODataValidationSettings settings)
 {
     IncrementCount("ValidateParameterQueryNode");
     base.ValidateRangeVariable(rangeVariable, settings);
 }
        /// <summary>
        /// Override this method to validate the parameter used in the filter query.
        /// </summary>
        /// <remarks>
        /// This method is intended to be called from method overrides in subclasses. This method also supports unit-testing scenarios and is not intended to be called from user code.
        /// Call the Validate method to validate a <see cref="FilterQueryOption"/> instance.
        /// </remarks>
        /// <param name="rangeVariable"></param>
        /// <param name="settings"></param>
        public virtual void ValidateRangeVariable(RangeVariable rangeVariable, ODataValidationSettings settings)
        {
            if (rangeVariable == null)
            {
                throw Error.ArgumentNull("rangeVariable");
            }

            if (settings == null)
            {
                throw Error.ArgumentNull("settings");
            }

            // no default validation logic here
        }
Example #9
0
 /// <summary>
 /// Redirects the comparison of parameter query nodes.
 /// </summary>
 /// <param name="left">Left side of comparison</param>
 /// <param name="right">Right side of comparison</param>
 /// <returns>True if equal, otherwise false</returns>
 private bool CompareParameters(RangeVariable left, RangeVariable right)
 {
     if (left is EntityRangeVariable && right is EntityRangeVariable)
         return this.Compare((EntityRangeVariable)left, (EntityRangeVariable)right);
     if (left is NonentityRangeVariable && right is NonentityRangeVariable)
         return this.Compare((NonentityRangeVariable)left, (NonentityRangeVariable)right);
     return false;
 }
Example #10
0
 /// <summary>
 /// Create a AnyNode
 /// </summary>
 /// <param name="parameters">The name of the parameter list.</param>
 /// <param name="currentRangeVariable">The name of the new range variable being added by this AnyNode</param>
 public AnyNode(Collection <RangeVariable> parameters, RangeVariable currentRangeVariable)
     : base(parameters, currentRangeVariable)
 {
 }
Example #11
0
 /// <summary>
 /// Create an AllNode
 /// </summary>
 /// <param name="rangeVariables">The name of the rangeVariables list.</param>
 /// <param name="currentRangeVariable">The new range variable being added by this all node</param>
 public AllNode(Collection <RangeVariable> rangeVariables, RangeVariable currentRangeVariable)
     : base(rangeVariables, currentRangeVariable)
 {
 }
Example #12
0
 /// <summary>
 /// Creates an AnyNode or an AllNode from the given 
 /// </summary>
 /// <param name="state">State of binding.</param>
 /// <param name="parent">Parent node to the lambda.</param>
 /// <param name="lambdaExpression">Bound Lambda expression.</param>
 /// <param name="newRangeVariable">The new range variable being added by this lambda node.</param>
 /// <param name="queryTokenKind">Token kind.</param>
 /// <returns>A new LambdaNode bound to metadata.</returns>
 internal static LambdaNode CreateLambdaNode(
     BindingState state,
     CollectionNode parent,                                           
     SingleValueNode lambdaExpression, 
     RangeVariable newRangeVariable,
     QueryTokenKind queryTokenKind)
 {
     LambdaNode lambdaNode;
     if (queryTokenKind == QueryTokenKind.Any)
     {
         lambdaNode = new AnyNode(new Collection<RangeVariable>(state.RangeVariables.ToList()), newRangeVariable)
             {
                 Body = lambdaExpression,
                 Source = parent,
             };
     }
     else
     {
         Debug.Assert(queryTokenKind == QueryTokenKind.All, "LambdaQueryNodes must be Any or All only.");
         lambdaNode = new AllNode(new Collection<RangeVariable>(state.RangeVariables.ToList()), newRangeVariable)
             {
                 Body = lambdaExpression,
                 Source = parent,
             };
     }
     
     return lambdaNode;
 }
Example #13
0
 public static void VeryfyRangeVariablesAreEqual(RangeVariable expected, RangeVariable actual,
                                         AssertionHandler assert)
 {
     assert.AreEqual(expected.Name, actual.Name, "Name is different");
     assert.AreEqual(expected.Kind, actual.Kind, "InternalKind is different");
 }
Example #14
0
 /// <summary>
 /// Create a LambdaNode
 /// </summary>
 /// <param name="rangeVariables">The collection of rangeVariables in scope for this Any or All.</param>
 /// <param name="currentRangeVariable">The newest range variable added for by this Any or All.</param>
 protected LambdaNode(Collection<RangeVariable> rangeVariables, RangeVariable currentRangeVariable)
 {
     this.rangeVariables = rangeVariables;
     this.currentRangeVariable = currentRangeVariable;
 }
 /// <summary>
 /// Writes Range Variable node to string
 /// </summary>
 /// <param name="node">Node to write to string</param>
 /// <returns>String representation of node.</returns>
 private static string ToStringParameter(RangeVariable node)
 {
     if (node is EntityRangeVariable)
         return ToString((EntityRangeVariable)node);
     if (node is NonentityRangeVariable)
         return ToString((NonentityRangeVariable)node);
     return String.Empty;
 }