public override DbExpression Visit(DbGroupByExpression expression)
        {
            EntityUtil.CheckArgumentNull(expression, "expression");

            DbExpression result = expression;

            DbGroupExpressionBinding newInput = this.VisitGroupExpressionBinding(expression.Input);

            this.EnterScope(newInput.Variable);
            IList <DbExpression> newKeys = this.VisitExpressionList(expression.Keys);

            this.ExitScope();
            this.EnterScope(newInput.GroupVariable);
            IList <DbAggregate> newAggs = this.VisitList <DbAggregate>(expression.Aggregates, this.VisitAggregate);

            this.ExitScope();

            if (!object.ReferenceEquals(expression.Input, newInput) ||
                !object.ReferenceEquals(expression.Keys, newKeys) ||
                !object.ReferenceEquals(expression.Aggregates, newAggs))
            {
                RowType groupOutput =
                    TypeHelpers.GetEdmType <RowType>(TypeHelpers.GetEdmType <CollectionType>(expression.ResultType).TypeUsage);

                var boundKeys = groupOutput.Properties.Take(newKeys.Count).Select(p => p.Name).Zip(newKeys).ToList();
                var boundAggs = groupOutput.Properties.Skip(newKeys.Count).Select(p => p.Name).Zip(newAggs).ToList();

                result = CqtBuilder.GroupBy(newInput, boundKeys, boundAggs);
            }
            NotifyIfChanged(expression, result);
            return(result);
        }
        /// <summary>
        /// Visitor pattern method for <see cref="DbGroupByExpression"/>.
        /// </summary>
        /// <param name="expression">The DbExpression that is being visited.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is null</exception>
        public override void Visit(DbGroupByExpression expression)
        {
            // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
            EntityUtil.CheckArgumentNull(expression, "expression");

            VisitGroupExpressionBindingPre(expression.Input);
            VisitExpressionList(expression.Keys);
            VisitGroupExpressionBindingMid(expression.Input);
            VisitAggregateList(expression.Aggregates);
            VisitGroupExpressionBindingPost(expression.Input);
        }
 /// <summary>
 /// Typed visitor pattern method for DbGroupByExpression.
 /// </summary>
 /// <param name="expression">The DbGroupByExpression that is being visited.</param>
 /// <returns>An instance of TResultType.</returns>
 public abstract TResultType Visit(DbGroupByExpression expression);
Esempio n. 4
0
 /// <summary>
 /// Visitor pattern method for DbGroupByExpression.
 /// </summary>
 /// <param name="expression">The DbGroupByExpression that is being visited.</param>
 public abstract void Visit(DbGroupByExpression expression);