System.Data.Common.CommandTrees.DefaultExpressionVisitor.VisitGroupExpressionBinding(System.Data.Common.CommandTrees.DbGroupExpressionBinding)

Here are the examples of the csharp api class System.Data.Common.CommandTrees.DefaultExpressionVisitor.VisitGroupExpressionBinding(System.Data.Common.CommandTrees.DbGroupExpressionBinding) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: referencesource
Source File: DefaultExpressionVisitor.cs
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;
        }