Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Translate GroupBy-Aggregate when using result selector #18415

Merged
merged 2 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,12 @@ protected override ShapedQueryExpression TranslateGroupBy(ShapedQueryExpression
return source;
}

var keyAccessExpression = Expression.MakeMemberAccess(
source.ShaperExpression,
source.ShaperExpression.Type.GetTypeInfo().GetMember(nameof(IGrouping<int, int>.Key))[0]);

var original1 = resultSelector.Parameters[0];
var original2 = resultSelector.Parameters[1];

var newResultSelectorBody = new ReplacingExpressionVisitor(
new Dictionary<Expression, Expression> {
{ original1, keyAccessExpression },
{ original1, ((GroupByShaperExpression)source.ShaperExpression).KeySelector },
{ original2, source.ShaperExpression }
}).Visit(resultSelector.Body);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,13 @@ protected override ShapedQueryExpression TranslateGroupBy(
return source;
}

var keyAccessExpression = Expression.MakeMemberAccess(
source.ShaperExpression,
source.ShaperExpression.Type.GetTypeInfo().GetMember(nameof(IGrouping<int, int>.Key))[0]);

var original1 = resultSelector.Parameters[0];
var original2 = resultSelector.Parameters[1];

var newResultSelectorBody = new ReplacingExpressionVisitor(
new Dictionary<Expression, Expression>
{
{ original1, keyAccessExpression }, { original2, source.ShaperExpression }
{ original1, translatedKey }, { original2, source.ShaperExpression }
})
.Visit(resultSelector.Body);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7802,7 +7802,7 @@ from g in ss.Set<Gear>()
elementSorter: e => (e.Name, e.Count, e.Sum));
}

[ConditionalTheory(Skip = "issue #18267")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Complex_GroupBy_after_set_operator_using_result_selector(bool isAsync)
{
Expand Down