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);
        }