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)
6868 var groupExpression = ( GroupByExpression ) node . Expression ;
6969 if ( _accumulatorLookup != null && _accumulatorLookup . Contains ( node . CorrelationId ) )
7070 {
71+ var oldAccumulatorLookup = _accumulatorLookup ;
7172 var source = Visit ( groupExpression . Source ) ;
73+ _accumulatorLookup = oldAccumulatorLookup ;
74+
7275 var accumulators = new List < AccumulatorExpression > ( ) ;
7376 var fieldExpressions = new List < FieldExpression > ( ) ;
7477 var comparer = new ExpressionComparer ( ) ;
Original file line number Diff line number Diff line change @@ -110,6 +110,26 @@ public async Task AverageAsync_with_selector()
110110 result . Should ( ) . Be ( 61 ) ;
111111 }
112112
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+
113133 [ Fact ]
114134 public void Count ( )
115135 {
You can’t perform that action at this time.
0 commit comments