mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
修改: row_number排序不一致
修改遗漏的SqlServerSelect
This commit is contained in:
parent
5ed9888fa1
commit
6085fb7e42
@ -41,7 +41,8 @@ namespace FreeSql.SqlServer.Curd
|
||||
//if (_limit > 0) sb.Append("TOP ").Append(_skip + _limit).Append(" "); //TOP 会引发 __rownum__ 无序的问题
|
||||
if (_skip <= 0 && _limit > 0) sb.Append("TOP ").Append(_limit).Append(" ");
|
||||
sb.Append(field);
|
||||
if (_skip > 0)
|
||||
|
||||
if (_limit > 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_orderby))
|
||||
{
|
||||
@ -49,7 +50,8 @@ namespace FreeSql.SqlServer.Curd
|
||||
if (pktb != null) _orderby = string.Concat(" \r\nORDER BY ", pktb.Alias, ".", _commonUtils.QuoteSqlName(pktb?.Table.Primarys.First().Attribute.Name));
|
||||
else _orderby = string.Concat(" \r\nORDER BY ", _tables.First().Alias, ".", _commonUtils.QuoteSqlName(_tables.First().Table.Columns.First().Value.Attribute.Name));
|
||||
}
|
||||
sb.Append(", ROW_NUMBER() OVER(").Append(_orderby).Append(") AS __rownum__");
|
||||
if (_skip > 0) // 注意这个判断,大于 0 才使用 ROW_NUMBER ,否则属于第一页直接使用 TOP
|
||||
sb.Append(", ROW_NUMBER() OVER(").Append(_orderby).Append(") AS __rownum__");
|
||||
}
|
||||
sb.Append(" \r\nFROM ");
|
||||
var tbsjoin = _tables.Where(a => a.Type != SelectTableInfoType.From).ToArray();
|
||||
|
Loading…
x
Reference in New Issue
Block a user