Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f4ceb18

Browse files
committed
Refactor FirebirdSqlServerExpression to use DialectProvider
1 parent 183142c commit f4ceb18

File tree

2 files changed

+41
-28
lines changed

2 files changed

+41
-28
lines changed

src/ServiceStack.OrmLite.Firebird/FirebirdOrmLiteDialectProvider.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,48 @@ public override string ToChangeColumnNameStatement(Type modelType,
806806
GetQuotedColumnName(fieldDef.FieldName));
807807
}
808808
#endregion DDL
809+
810+
public override string ToSelectStatement(ModelDefinition modelDef,
811+
string selectExpression,
812+
string bodyExpression,
813+
string orderByExpression = null,
814+
int? offset = null,
815+
int? rows = null)
816+
{
817+
818+
var sb = new StringBuilder(selectExpression);
819+
sb.Append(bodyExpression);
820+
if (orderByExpression != null)
821+
{
822+
sb.Append(orderByExpression);
823+
}
824+
825+
if (offset != null)
826+
{
827+
int fromRow = offset.Value + 1;
828+
if (fromRow <= 0)
829+
throw new ArgumentException(
830+
string.Format("Skip value:'{0}' must be>=0", offset.Value));
831+
string toRow;
832+
if (rows.HasValue)
833+
{
834+
if (rows.Value < 0)
835+
{
836+
throw new ArgumentException(string.Format("Rows value:'{0}' must be>=0", rows.Value));
837+
}
838+
toRow = string.Format("TO {0}", fromRow + rows.Value - 1);
839+
}
840+
else
841+
{
842+
toRow = string.Empty;
843+
}
844+
sb.Append(string.Format("ROWS {0} {1}", fromRow, toRow));
845+
}
846+
847+
return sb.ToString();
848+
}
809849
}
850+
810851
}
811852

812853
/*

src/ServiceStack.OrmLite.Firebird/FirebirdSqlExpression.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -160,34 +160,6 @@ private bool IsFalseExpression(object exp)
160160
{
161161
return (exp.ToString() == _falseExpression);
162162
}
163-
164-
public override string LimitExpression
165-
{
166-
get
167-
{
168-
if (!Offset.HasValue) return "";
169-
int fromRow = Offset.Value + 1;
170-
if (fromRow <= 0)
171-
throw new ArgumentException(
172-
string.Format("Skip value:'{0}' must be>=0", Offset.Value));
173-
string toRow;
174-
if (Rows.HasValue)
175-
{
176-
if (Rows.Value < 0)
177-
{
178-
throw new ArgumentException(
179-
string.Format("Rows value:'{0}' must be>=0", Rows.Value));
180-
}
181-
toRow = string.Format("TO {0}", fromRow + Rows.Value - 1);
182-
}
183-
else
184-
{
185-
toRow = string.Empty;
186-
}
187-
return string.Format("ROWS {0} {1}", fromRow, toRow);
188-
}
189-
}
190-
191163
}
192164
}
193165

0 commit comments

Comments
 (0)