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 +10
-14
lines changed
src/ServiceStack.OrmLite/Expressions Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -374,7 +374,7 @@ public virtual SqlExpression<T> Limit(int skip, int rows)
374
374
/// </param>
375
375
public virtual SqlExpression < T > Limit ( int ? skip , int ? rows )
376
376
{
377
- Offset = skip ?? 0 ;
377
+ Offset = skip ;
378
378
Rows = rows ;
379
379
return this ;
380
380
}
@@ -387,7 +387,7 @@ public virtual SqlExpression<T> Limit(int? skip, int? rows)
387
387
/// </param>
388
388
public virtual SqlExpression < T > Limit ( int rows )
389
389
{
390
- Offset = 0 ;
390
+ Offset = null ;
391
391
Rows = rows ;
392
392
return this ;
393
393
}
@@ -626,17 +626,12 @@ public virtual string LimitExpression
626
626
{
627
627
get
628
628
{
629
- if ( ! Offset . HasValue ) return "" ;
630
- string rows ;
631
- if ( Rows . HasValue )
632
- {
633
- rows = string . Format ( ",{0}" , Rows . Value ) ;
634
- }
635
- else
636
- {
637
- rows = string . Empty ;
638
- }
639
- return string . Format ( "LIMIT {0}{1}" , Offset . Value , rows ) ;
629
+ if ( Offset == null && Rows == null )
630
+ return "" ;
631
+
632
+ return Offset == null
633
+ ? "LIMIT " + Rows
634
+ : "LIMIT " + Rows . GetValueOrDefault ( int . MaxValue ) + " OFFSET " + Offset ;
640
635
}
641
636
}
642
637
@@ -1130,7 +1125,8 @@ public IList<string> GetAllFields()
1130
1125
1131
1126
protected virtual string ApplyPaging ( string sql )
1132
1127
{
1133
- sql = sql + ( string . IsNullOrEmpty ( LimitExpression ) ? "" : "\n " + LimitExpression ) ;
1128
+ var limitExpression = LimitExpression ;
1129
+ sql = sql + ( string . IsNullOrEmpty ( limitExpression ) ? "" : "\n " + limitExpression ) ;
1134
1130
return sql ;
1135
1131
}
1136
1132
You can’t perform that action at this time.
0 commit comments