mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-16 16:50:41 +08:00
-
This commit is contained in:
parent
a0a22b8449
commit
f9d06b6d4d
@ -161,7 +161,7 @@ namespace OrmTest.Demo
|
||||
int count = 0;
|
||||
|
||||
var list4 = db.Queryable<Student, School>((st, sc) => st.SchoolId == sc.Id)
|
||||
.PartitionBy(st => new { st.Name }).Take(1).OrderBy(st => st.Id,OrderByType.Desc).Select(st => st).ToPageList(1, 1000, ref count);
|
||||
.PartitionBy(st => new { st.Name }).Take(2).OrderBy(st => st.Id,OrderByType.Desc).Select(st => st).ToPageList(1, 1000, ref count);
|
||||
|
||||
//SqlFunc.AggregateSum(object thisValue)
|
||||
//SqlFunc.AggregateAvg<TResult>(TResult thisValue)
|
||||
|
@ -225,7 +225,7 @@ namespace SqlSugar
|
||||
{
|
||||
string oldOrderBy = this.OrderByValue;
|
||||
string externalOrderBy = oldOrderBy;
|
||||
var isCount = this.IsCount&&this.PartitionByValue.IsNullOrEmpty();
|
||||
var isIgnoreOrderBy = this.IsCount&&this.PartitionByValue.IsNullOrEmpty();
|
||||
AppendFilter();
|
||||
sql = new StringBuilder();
|
||||
if (this.OrderByValue == null && (Skip != null || Take != null)) this.OrderByValue = " ORDER BY GetDate() ";
|
||||
@ -237,10 +237,10 @@ namespace SqlSugar
|
||||
var rowNumberString = string.Format(",ROW_NUMBER() OVER({0}) AS RowIndex ", GetOrderByString);
|
||||
string groupByValue = GetGroupByString + HavingInfos;
|
||||
string orderByValue = (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null;
|
||||
if (isCount) { orderByValue = null; }
|
||||
if (isIgnoreOrderBy) { orderByValue = null; }
|
||||
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, groupByValue, orderByValue);
|
||||
sql.Replace(UtilConstants.ReplaceKey, isRowNumber ? (isCount ? null : rowNumberString) : null);
|
||||
if (isCount) { this.OrderByValue = oldOrderBy; return sql.ToString(); }
|
||||
sql.Replace(UtilConstants.ReplaceKey, isRowNumber ? (isIgnoreOrderBy ? null : rowNumberString) : null);
|
||||
if (isIgnoreOrderBy) { this.OrderByValue = oldOrderBy; return sql.ToString(); }
|
||||
var result = ToPageSql(sql.ToString(), this.Take, this.Skip);
|
||||
if (ExternalPageIndex > 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user