mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-25 01:14:33 +08:00
Bug Subquery.OrderBy.First by SqlServer
This commit is contained in:
parent
9b8c527d4e
commit
d09db49811
@ -14,10 +14,14 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public override string RemoveParentheses(string sql)
|
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";
|
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;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user