private static Expression HandleGroup( EntityQueryModelVisitor entityQueryModelVisitor, GroupResultOperator groupResultOperator, QueryModel queryModel) { var keySelector = entityQueryModelVisitor .ReplaceClauseReferences( groupResultOperator.KeySelector, queryModel.MainFromClause); var elementSelector = entityQueryModelVisitor .ReplaceClauseReferences( groupResultOperator.ElementSelector, queryModel.MainFromClause); var expression = Expression.Call( entityQueryModelVisitor.LinqOperatorProvider.GroupBy .MakeGenericMethod( entityQueryModelVisitor.Expression.Type.GetSequenceType(), keySelector.Type, elementSelector.Type), entityQueryModelVisitor.Expression, Expression.Lambda(keySelector, entityQueryModelVisitor.CurrentParameter), Expression.Lambda(elementSelector, entityQueryModelVisitor.CurrentParameter)); entityQueryModelVisitor.CurrentParameter = Expression.Parameter(expression.Type.GetSequenceType(), groupResultOperator.ItemName); entityQueryModelVisitor .AddOrUpdateMapping(groupResultOperator, entityQueryModelVisitor.CurrentParameter); return(expression); }
private static Expression HandleGroup( EntityQueryModelVisitor entityQueryModelVisitor, GroupResultOperator groupResultOperator, QueryModel queryModel) { var keySelector = entityQueryModelVisitor .ReplaceClauseReferences( groupResultOperator.KeySelector, queryModel.MainFromClause); var elementSelector = entityQueryModelVisitor .ReplaceClauseReferences( groupResultOperator.ElementSelector, queryModel.MainFromClause); var expression = Expression.Call( entityQueryModelVisitor.LinqOperatorProvider.GroupBy .MakeGenericMethod( entityQueryModelVisitor.Expression.Type.GetSequenceType(), keySelector.Type, elementSelector.Type), entityQueryModelVisitor.Expression, Expression.Lambda(keySelector, entityQueryModelVisitor.CurrentParameter), Expression.Lambda(elementSelector, entityQueryModelVisitor.CurrentParameter)); entityQueryModelVisitor.CurrentParameter = Expression.Parameter(expression.Type.GetSequenceType(), groupResultOperator.ItemName); entityQueryModelVisitor .AddOrUpdateMapping(groupResultOperator, entityQueryModelVisitor.CurrentParameter); return expression; }