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

Commit e3bf135

Browse files
committed
refactor last commit to make more concise/readable
1 parent bb7ee31 commit e3bf135

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/ServiceStack.OrmLite.SqlServer/SqlServerExpressionVisitor.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ public override string ToSelectStatement()
2626

2727
sql = base.ToSelectStatement();
2828
if (sql == null || sql.Length < "SELECT".Length) return sql;
29-
bool hasDistinctInBaseQuery = sql.StartsWithIgnoreCase("SELECT DISTINCT");
30-
string stringToRemoveFromBaseQuery = hasDistinctInBaseQuery ? "SELECT DISTINCT" : "SELECT";
31-
sql = stringToRemoveFromBaseQuery + " TOP " + take + " " + sql.Substring(stringToRemoveFromBaseQuery.Length, sql.Length - stringToRemoveFromBaseQuery.Length);
29+
var selectType = sql.StartsWithIgnoreCase("SELECT DISTINCT") ? "SELECT DISTINCT" : "SELECT";
30+
sql = selectType + " TOP " + take + " " + sql.Substring(selectType.Length, sql.Length - selectType.Length);
3231
return sql;
3332
}
3433

0 commit comments

Comments
 (0)