Ejemplo n.º 1
0
        public ApplyClause BindApply(IEnumerable <QueryToken> tokens)
        {
            ExceptionUtils.CheckArgumentNotNull(tokens, "tokens");

            List <TransformationNode> transformations = new List <TransformationNode>();

            foreach (QueryToken token in tokens)
            {
                switch (token.Kind)
                {
                case QueryTokenKind.Aggregate:
                    AggregateTransformationNode aggregate = BindAggregateToken((AggregateToken)(token));
                    transformations.Add(aggregate);
                    aggregateExpressionsCache     = aggregate.AggregateExpressions;
                    state.AggregatedPropertyNames = new HashSet <EndPathToken>(aggregate.AggregateExpressions.Select(statement => new EndPathToken(statement.Alias, null)));
                    state.IsCollapsed             = true;
                    break;

                case QueryTokenKind.AggregateGroupBy:
                    GroupByTransformationNode groupBy = BindGroupByToken((GroupByToken)(token));
                    transformations.Add(groupBy);
                    state.IsCollapsed = true;
                    break;

                case QueryTokenKind.Compute:
                    var compute = BindComputeToken((ComputeToken)token);
                    transformations.Add(compute);
                    state.AggregatedPropertyNames = new HashSet <EndPathToken>(compute.Expressions.Select(statement => new EndPathToken(statement.Alias, null)));
                    break;

                case QueryTokenKind.Expand:
                    SelectExpandClause       expandClause = SelectExpandSemanticBinder.Bind(this.odataPathInfo, (ExpandToken)token, null, this.configuration, null);
                    ExpandTransformationNode expandNode   = new ExpandTransformationNode(expandClause);
                    transformations.Add(expandNode);
                    break;

                default:
                    FilterClause             filterClause = this.filterBinder.BindFilter(token);
                    FilterTransformationNode filterNode   = new FilterTransformationNode(filterClause);
                    transformations.Add(filterNode);
                    break;
                }
            }

            return(new ApplyClause(transformations));
        }
Ejemplo n.º 2
0
        public ApplyClause BindApply(IEnumerable <QueryToken> tokens)
        {
            ExceptionUtils.CheckArgumentNotNull(tokens, "tokens");

            var transformations = new List <TransformationNode>();

            foreach (var token in tokens)
            {
                switch (token.Kind)
                {
                case QueryTokenKind.Aggregate:
                    AggregateTransformationNode aggregate = BindAggregateToken((AggregateToken)(token));
                    transformations.Add(aggregate);
                    aggregateExpressionsCache     = aggregate.Expressions;
                    state.AggregatedPropertyNames = aggregate.Expressions.Select(statement => statement.Alias).ToList();
                    break;

                case QueryTokenKind.AggregateGroupBy:
                    GroupByTransformationNode groupBy = BindGroupByToken((GroupByToken)(token));
                    transformations.Add(groupBy);
                    break;

                case QueryTokenKind.Compute:
                    ComputeClause             computeClause = this.computeBinder.BindCompute((ComputeToken)token);
                    ComputeTransformationNode computeNode   = new ComputeTransformationNode(computeClause);
                    transformations.Add(computeNode);
                    state.AggregatedPropertyNames = computeNode.ComputeClause.ComputedItems.Select(statement => statement.Alias).ToList();
                    break;

                default:
                    FilterClause             filterClause = this.filterBinder.BindFilter(token);
                    FilterTransformationNode filterNode   = new FilterTransformationNode(filterClause);
                    transformations.Add(filterNode);
                    break;
                }
            }

            return(new ApplyClause(transformations));
        }