Bug Subquery.OrderBy.First by SqlServer

This commit is contained in:
sunkaixuan 2023-04-26 12:48:59 +08:00
parent 9b8c527d4e
commit d09db49811

View File

@ -14,10 +14,14 @@ namespace SqlSugar
public override string RemoveParentheses(string sql)
{
if (sql.Contains("ORDER BY"))
if (sql.Contains("ORDER BY")&&!sql.StartsWith("(SELECT TOP 1"))
{
sql = $"SELECT * FROM {sql.Replace("(SELECT ", "(SELECT TOP 1000000")} TEMP";
}
else if (sql.Contains("ORDER BY") && sql.StartsWith("(SELECT TOP 1"))
{
sql = $"SELECT * FROM ({ sql}) TEMP";
}
return sql;
}