Ejemplo n.º 1
0
        /// <summary>
        /// Create a GroupByTransformationNode.
        /// </summary>
        /// <param name="groupingProperties">A list of <see cref="GroupByPropertyNode"/>.</param>
        /// <param name="childTransformations">The child <see cref="TransformationNode"/>.</param>
        /// <param name="source">The <see cref="CollectionNode"/> representing the source.</param>
        public GroupByTransformationNode(
            IList<GroupByPropertyNode> groupingProperties,
            TransformationNode childTransformations,
            CollectionNode source)
        {
            ExceptionUtils.CheckArgumentNotNull(groupingProperties, "groupingProperties");

            this.groupingProperties = groupingProperties;
            this.childTransformations = childTransformations;
            this.source = source;
        }
        /// <summary>
        /// Creates a <see cref="NonentityRangeVariable"/>.
        /// </summary>
        /// <param name="name"> The name of the associated range variable.</param>
        /// <param name="typeReference">The type of the value the range variable represents.</param>
        /// <param name="collectionNode">The collection that this rangeVariable node iterates over, can be null in the case of single value nodes.</param>
        /// <exception cref="System.ArgumentNullException">Throws if the input name is null.</exception>
        /// <exception cref="ArgumentException">Throws if the input type reference is an entity type.</exception>
        public NonentityRangeVariable(string name, IEdmTypeReference typeReference, CollectionNode collectionNode)
        {
            ExceptionUtils.CheckArgumentNotNull(name, "name");
            this.name = name;
            if (typeReference != null)
            {
                if (typeReference.Definition.TypeKind == EdmTypeKind.Entity)
                {
                    throw new ArgumentException(
                              ODataErrorStrings.Nodes_NonentityParameterQueryNodeWithEntityType(typeReference.FullName()));
                }
            }

            this.typeReference  = typeReference;
            this.collectionNode = collectionNode;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a <see cref="NonentityRangeVariable"/>.
        /// </summary>
        /// <param name="name"> The name of the associated range variable.</param>
        /// <param name="typeReference">The type of the value the range variable represents.</param>
        /// <param name="collectionNode">The collection that this rangeVariable node iterates over, can be null in the case of single value nodes.</param>
        /// <exception cref="System.ArgumentNullException">Throws if the input name is null.</exception>
        /// <exception cref="ArgumentException">Throws if the input type reference is an entity type.</exception>
        public NonentityRangeVariable(string name, IEdmTypeReference typeReference, CollectionNode collectionNode)
        {
            ExceptionUtils.CheckArgumentNotNull(name, "name");
            this.name = name;
            if (typeReference != null)
            {
                if (typeReference.Definition.TypeKind == EdmTypeKind.Entity)
                {
                    throw new ArgumentException(
                        ODataErrorStrings.Nodes_NonentityParameterQueryNodeWithEntityType(typeReference.FullName()));
                }
            }

            this.typeReference = typeReference;
            this.collectionNode = collectionNode;
        }
Ejemplo n.º 4
0
        private void ValidateCollectionNode(CollectionNode node, ODataValidationSettings settings)
        {
            switch (node.Kind)
            {
                case QueryNodeKind.CollectionPropertyAccess:
                    CollectionPropertyAccessNode propertyAccessNode = node as CollectionPropertyAccessNode;
                    ValidateCollectionPropertyAccessNode(propertyAccessNode, settings);
                    break;

                case QueryNodeKind.CollectionNavigationNode:
                    CollectionNavigationNode navigationNode = node as CollectionNavigationNode;
                    ValidateNavigationPropertyNode(navigationNode.Source, navigationNode.NavigationProperty, settings);
                    break;

                case QueryNodeKind.EntityCollectionCast:
                    ValidateEntityCollectionCastNode(node as EntityCollectionCastNode, settings);
                    break;
            }
        }
Ejemplo n.º 5
0
        private void ValidateCollectionNode(CollectionNode node, ODataValidationSettings settings)
        {
            switch (node.Kind)
            {
                case QueryNodeKind.CollectionPropertyAccess:
                    CollectionPropertyAccessNode propertyAccessNode = node as CollectionPropertyAccessNode;
                    ValidateCollectionPropertyAccessNode(propertyAccessNode, settings);
                    break;

                case QueryNodeKind.CollectionNavigationNode:
                    CollectionNavigationNode navigationNode = node as CollectionNavigationNode;
                    ValidateNavigationPropertyNode(navigationNode.Source, navigationNode.NavigationProperty, settings);
                    break;

                case QueryNodeKind.EntityCollectionCast:
                    ValidateEntityCollectionCastNode(node as EntityCollectionCastNode, settings);
                    break;

                case QueryNodeKind.CollectionFunctionCall:
                case QueryNodeKind.EntityCollectionFunctionCall:
                case QueryNodeKind.CollectionOpenPropertyAccess:
                case QueryNodeKind.CollectionPropertyCast:
                    // Unused or have unknown uses.
                default:
                    throw Error.NotSupported(SRResources.QueryNodeValidationNotSupported, node.Kind, typeof(FilterQueryValidator).Name);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a ParameterQueryNode for an explicit parameter.
        /// </summary>
        /// <param name="parameter">Name of the parameter.</param>
        /// <param name="nodeToIterateOver">CollectionNode that the parameter is iterating over.</param>
        /// <returns>A new RangeVariable.</returns>
        internal static RangeVariable CreateParameterNode(string parameter, CollectionNode nodeToIterateOver)
        {
            IEdmTypeReference elementType = nodeToIterateOver.ItemType;

            if (elementType != null && elementType.IsEntity())
            {
                var entityCollectionNode = nodeToIterateOver as EntityCollectionNode;
                Debug.Assert(entityCollectionNode != null, "IF the element type was entity, the node type should be an entity collection");
                return new EntityRangeVariable(parameter, elementType as IEdmEntityTypeReference, entityCollectionNode);
            }

            return new NonentityRangeVariable(parameter, elementType, null);
        }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructs a new <see cref="CountNode"/>.
        /// </summary>
        /// <param name="source">The value containing the property.</param>
        /// <exception cref="System.ArgumentNullException">Throws if the input source is null.</exception>
        public CountNode(CollectionNode source)
        {
            ExceptionUtils.CheckArgumentNotNull(source, "source");

            this.source = source;
        }