This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
tests/ServiceStack.OrmLite.Tests/Expression Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,34 @@ public void Can_do_ToCountStatement_with_SqlExpression_if_where_expression_refer
244
244
}
245
245
}
246
246
247
+ [ Test ]
248
+ public void Can_do_ToCountStatement_with_SqlExpression_if_expression_has_groupby ( )
249
+ {
250
+ using ( var db = OpenDbConnection ( ) )
251
+ {
252
+ db . DropAndCreateTable < LetterFrequency > ( ) ;
253
+
254
+ db . Insert ( new LetterFrequency { Letter = "A" } ) ;
255
+ db . Insert ( new LetterFrequency { Letter = "A" } ) ;
256
+ db . Insert ( new LetterFrequency { Letter = "A" } ) ;
257
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
258
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
259
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
260
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
261
+
262
+
263
+ var query = db . From < LetterFrequency > ( )
264
+ . Select ( x => x . Letter )
265
+ . GroupBy ( x => x . Letter ) ;
266
+
267
+ query . ToCountStatement ( ) . Print ( ) ;
268
+
269
+ var count = db . Count ( query ) ;
270
+
271
+ Assert . That ( count , Is . EqualTo ( 2 ) ) ;
272
+ }
273
+ }
274
+
247
275
[ Test ]
248
276
public void Can_OrderBy_Fields_with_different_sort_directions ( )
249
277
{
You can’t perform that action at this time.
0 commit comments