This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -683,9 +683,11 @@ public virtual SqlExpression<T> OrderBy(long columnIndex)
683
683
public virtual SqlExpression < T > UnsafeOrderBy ( string orderBy )
684
684
{
685
685
orderByProperties . Clear ( ) ;
686
- this . orderBy = string . IsNullOrEmpty ( orderBy )
687
- ? null
688
- : "ORDER BY " + orderBy ;
686
+ if ( ! string . IsNullOrEmpty ( orderBy ) )
687
+ {
688
+ orderByProperties . Add ( orderBy ) ;
689
+ }
690
+ BuildOrderByClauseInternal ( ) ;
689
691
return this ;
690
692
}
691
693
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public abstract class OrmLiteConverter : IOrmLiteConverter
40
40
public IOrmLiteDialectProvider DialectProvider { get ; set ; }
41
41
42
42
/// <summary>
43
- /// SQL Column Definiton used in CREATE Table.
43
+ /// SQL Column Definition used in CREATE Table.
44
44
/// </summary>
45
45
public abstract string ColumnDefinition { get ; }
46
46
Original file line number Diff line number Diff line change 1
1
using System . Linq ;
2
2
using NUnit . Framework ;
3
3
using ServiceStack . OrmLite . Tests . Expression ;
4
+ using ServiceStack . Text ;
4
5
5
6
namespace ServiceStack . OrmLite . Tests
6
7
{
@@ -29,5 +30,28 @@ public void Can_order_by_random()
29
30
Assert . That ( ! rowIds1 . SequenceEqual ( rowIds2 ) ) ;
30
31
}
31
32
}
33
+
34
+ [ Test ]
35
+ public void Can_OrderBy_and_ThenBy ( )
36
+ {
37
+ using ( var db = OpenDbConnection ( ) )
38
+ {
39
+ db . DropAndCreateTable < LetterFrequency > ( ) ;
40
+
41
+ db . Insert ( new LetterFrequency { Letter = "C" } ) ;
42
+ db . Insert ( new LetterFrequency { Letter = "C" } ) ;
43
+ db . Insert ( new LetterFrequency { Letter = "B" } ) ;
44
+ db . Insert ( new LetterFrequency { Letter = "A" } ) ;
45
+
46
+ var q = db . From < LetterFrequency > ( ) ;
47
+ q . OrderBy ( nameof ( LetterFrequency . Letter ) )
48
+ . ThenBy ( nameof ( LetterFrequency . Id ) ) ;
49
+
50
+ var tracks = db . Select ( q ) ;
51
+
52
+ Assert . That ( tracks . First ( ) . Letter , Is . EqualTo ( "A" ) ) ;
53
+ Assert . That ( tracks . Last ( ) . Letter , Is . EqualTo ( "C" ) ) ;
54
+ }
55
+ }
32
56
}
33
57
}
You can’t perform that action at this time.
0 commit comments