File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
src/MongoDB.Driver/Linq/Processors
tests/MongoDB.Driver.Tests/Linq Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,10 @@ private Expression VisitCorrelatedGroup(CorrelatedExpression node)
68
68
var groupExpression = ( GroupByExpression ) node . Expression ;
69
69
if ( _accumulatorLookup != null && _accumulatorLookup . Contains ( node . CorrelationId ) )
70
70
{
71
+ var oldAccumulatorLookup = _accumulatorLookup ;
71
72
var source = Visit ( groupExpression . Source ) ;
73
+ _accumulatorLookup = oldAccumulatorLookup ;
74
+
72
75
var accumulators = new List < AccumulatorExpression > ( ) ;
73
76
var fieldExpressions = new List < FieldExpression > ( ) ;
74
77
var comparer = new ExpressionComparer ( ) ;
Original file line number Diff line number Diff line change @@ -110,6 +110,26 @@ public async Task AverageAsync_with_selector()
110
110
result . Should ( ) . Be ( 61 ) ;
111
111
}
112
112
113
+ [ Fact ]
114
+ public void GroupBy_combined_with_a_previous_embedded_pipeline ( )
115
+ {
116
+ var bs = new List < string >
117
+ {
118
+ "Baloon" ,
119
+ "Balloon"
120
+ } ;
121
+ var query = CreateQuery ( )
122
+ . Where ( x => bs . Contains ( x . B ) )
123
+ . GroupBy ( x => x . A )
124
+ . Select ( x => x . Max ( y => y . C ) ) ;
125
+
126
+ Assert ( query ,
127
+ 1 ,
128
+ "{ $match: { 'B': { '$in': ['Baloon', 'Balloon'] } } }" ,
129
+ "{ $group: { '_id': '$A', '__agg0': { '$max': '$C' } } }" ,
130
+ "{ $project: { '__fld0': '$__agg0', '_id': 0 } }" ) ;
131
+ }
132
+
113
133
[ Fact ]
114
134
public void Count ( )
115
135
{
You can’t perform that action at this time.
0 commit comments