@@ -179,7 +179,7 @@ public async Task CountAsync_with_no_matches()
179
179
}
180
180
181
181
[ SkippableFact ]
182
- public void Distinct_followed_by_where ( )
182
+ public void Distinct_document_followed_by_where ( )
183
183
{
184
184
RequireServer . Where ( minimumVersion : "2.6.0" ) ;
185
185
var query = CreateQuery ( )
@@ -192,6 +192,68 @@ public void Distinct_followed_by_where()
192
192
"{ $match: { '_id.A': 'Awesome' } }" ) ;
193
193
}
194
194
195
+ [ SkippableFact ]
196
+ public void Distinct_document_preceded_by_select_where ( )
197
+ {
198
+ RequireServer . Where ( minimumVersion : "2.6.0" ) ;
199
+ var query = CreateQuery ( )
200
+ . Select ( x => new { x . A , x . B } )
201
+ . Where ( x => x . A == "Awesome" )
202
+ . Distinct ( ) ;
203
+
204
+ Assert ( query ,
205
+ 1 ,
206
+ "{ $project: { 'A': '$A', 'B': '$B', '_id': 0 } }" ,
207
+ "{ $match: { 'A': 'Awesome' } }" ,
208
+ "{ $group: { '_id': '$$ROOT' } }" ) ;
209
+ }
210
+
211
+ [ SkippableFact ]
212
+ public void Distinct_document_preceded_by_where_select ( )
213
+ {
214
+ RequireServer . Where ( minimumVersion : "2.6.0" ) ;
215
+ var query = CreateQuery ( )
216
+ . Where ( x => x . A == "Awesome" )
217
+ . Select ( x => new { x . A , x . B } )
218
+ . Distinct ( ) ;
219
+
220
+ Assert ( query ,
221
+ 1 ,
222
+ "{ $match: { 'A': 'Awesome' } }" ,
223
+ "{ $group: { '_id': { 'A': '$A', 'B': '$B' } } }" ) ;
224
+ }
225
+
226
+ [ SkippableFact ]
227
+ public void Distinct_field_preceded_by_where_select ( )
228
+ {
229
+ RequireServer . Where ( minimumVersion : "2.6.0" ) ;
230
+ var query = CreateQuery ( )
231
+ . Where ( x => x . A == "Awesome" )
232
+ . Select ( x => x . A )
233
+ . Distinct ( ) ;
234
+
235
+ Assert ( query ,
236
+ 1 ,
237
+ "{ $match: { 'A': 'Awesome' } }" ,
238
+ "{ $group: { '_id': '$A' } }" ) ;
239
+ }
240
+
241
+ [ SkippableFact ]
242
+ public void Distinct_field_preceded_by_select_where ( )
243
+ {
244
+ RequireServer . Where ( minimumVersion : "2.6.0" ) ;
245
+ var query = CreateQuery ( )
246
+ . Select ( x => x . A )
247
+ . Where ( x => x == "Awesome" )
248
+ . Distinct ( ) ;
249
+
250
+ Assert ( query ,
251
+ 1 ,
252
+ "{ $project: { 'A': '$A', '_id': 0 } }" ,
253
+ "{ $match: { 'A': 'Awesome' } }" ,
254
+ "{ $group: { '_id': '$A' } }" ) ;
255
+ }
256
+
195
257
[ Fact ]
196
258
public void First ( )
197
259
{
0 commit comments