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 @@ -243,6 +243,34 @@ public void Can_do_ToCountStatement_with_SqlExpression_if_where_expression_refer
243
243
}
244
244
}
245
245
246
+ [ Test ]
247
+ public void Can_do_ToCountStatement_with_SqlExpression_if_expression_has_groupby ( )
248
+ {
249
+ using ( var db = OpenDbConnection ( ) )
250
+ {
251
+ db . DropAndCreateTable < LetterFrequency > ( ) ;
252
+
253
+ db . Insert ( new LetterFrequency { Letter = "A" } ) ;
254
+ db . Insert ( new LetterFrequency { Letter = "A" } ) ;
255
+ db . Insert ( new LetterFrequency { Letter = "A" } ) ;
256
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
257
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
258
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
259
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
260
+
261
+
262
+ var query = db . From < LetterFrequency > ( )
263
+ . Select ( x => x . Letter )
264
+ . GroupBy ( x => x . Letter ) ;
265
+
266
+ query . ToCountStatement ( ) . Print ( ) ;
267
+
268
+ var count = db . Count ( query ) ;
269
+
270
+ Assert . That ( count , Is . EqualTo ( 2 ) ) ;
271
+ }
272
+ }
273
+
246
274
[ Test ]
247
275
public void Can_OrderBy_Fields_with_different_sort_directions ( )
248
276
{
You can’t perform that action at this time.
0 commit comments