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)
374374 /// </param>
375375 public virtual SqlExpression < T > Limit ( int ? skip , int ? rows )
376376 {
377- Offset = skip ?? 0 ;
377+ Offset = skip ;
378378 Rows = rows ;
379379 return this ;
380380 }
@@ -387,7 +387,7 @@ public virtual SqlExpression<T> Limit(int? skip, int? rows)
387387 /// </param>
388388 public virtual SqlExpression < T > Limit ( int rows )
389389 {
390- Offset = 0 ;
390+ Offset = null ;
391391 Rows = rows ;
392392 return this ;
393393 }
@@ -626,17 +626,12 @@ public virtual string LimitExpression
626626 {
627627 get
628628 {
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 ;
640635 }
641636 }
642637
@@ -1130,7 +1125,8 @@ public IList<string> GetAllFields()
11301125
11311126 protected virtual string ApplyPaging ( string sql )
11321127 {
1133- sql = sql + ( string . IsNullOrEmpty ( LimitExpression ) ? "" : "\n " + LimitExpression ) ;
1128+ var limitExpression = LimitExpression ;
1129+ sql = sql + ( string . IsNullOrEmpty ( limitExpression ) ? "" : "\n " + limitExpression ) ;
11341130 return sql ;
11351131 }
11361132
You can’t perform that action at this time.
0 commit comments