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

            this.groupingProperties  = groupingProperties;
            this.childTransformation = childTransformation;
            this.source = source;
        }
        /// <summary>
        /// Create a GroupByTransformationNode.
        /// </summary>
        /// <param name="groupingProperties">A list of <see cref="GroupByPropertyNode"/>.</param>
        /// <param name="childTransformation">The child <see cref="TransformationNode"/>.</param>
        /// <param name="source">The <see cref="CollectionNode"/> representing the source.</param>
        public GroupByTransformationNode(
            IList<GroupByPropertyNode> groupingProperties,
            TransformationNode childTransformation,
            CollectionNode source)
        {
            ExceptionUtils.CheckArgumentNotNull(groupingProperties, "groupingProperties");

            this.groupingProperties = groupingProperties;
            this.childTransformation = childTransformation;
            this.source = source;
        }
Example #3
0
        internal AggregationBinder(ODataQuerySettings settings, IAssembliesResolver assembliesResolver, Type elementType, IEdmModel model, TransformationNode transformation)
            : base(model, assembliesResolver, settings)
        {
            Contract.Assert(elementType != null);
            Contract.Assert(transformation != null);

            _elementType = elementType;
            _transformation = transformation;

            this._lambdaParameter = Expression.Parameter(this._elementType, "$it");

            switch (transformation.Kind)
            {
                case TransformationNodeKind.Aggregate:
                    var aggregateClause = this._transformation as AggregateTransformationNode;
                    _aggregateStatements = aggregateClause.Statements;
                    ResultClrType = AggregationDynamicTypeProvider.GetResultType<DynamicTypeWrapper>(_model, null, _aggregateStatements);
                    break;
                case TransformationNodeKind.GroupBy:
                    var groupByClause = this._transformation as GroupByTransformationNode;
                    _groupingProperties = groupByClause.GroupingProperties;
                    if (groupByClause.ChildTransformation != null)
                    {
                        if (groupByClause.ChildTransformation.Kind == TransformationNodeKind.Aggregate)
                        {
                            _aggregateStatements = ((AggregateTransformationNode)groupByClause.ChildTransformation).Statements;
                        }
                        else
                        {
                            throw new NotImplementedException();
                        }
                    }

                    _groupByClrType = AggregationDynamicTypeProvider.GetResultType<DynamicTypeWrapper>(_model, _groupingProperties, null);
                    ResultClrType = AggregationDynamicTypeProvider.GetResultType<DynamicTypeWrapper>(_model, _groupingProperties, _aggregateStatements);
                    break;
                default:
                    throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, SRResources.NotSupportedTransformationKind, transformation.Kind));
            }

            _groupByClrType = _groupByClrType ?? typeof(DynamicTypeWrapper);
        }