mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
-
This commit is contained in:
parent
f0881ba672
commit
a0a22b8449
@ -155,6 +155,8 @@ namespace OrmTest.Demo
|
|||||||
// group id,name take first
|
// group id,name take first
|
||||||
var list3 = db.Queryable<Student>()
|
var list3 = db.Queryable<Student>()
|
||||||
.PartitionBy(it => new { it.Id, it.Name }).Take(1).ToList();
|
.PartitionBy(it => new { it.Id, it.Name }).Take(1).ToList();
|
||||||
|
var list31 = db.Queryable<Student>()
|
||||||
|
.PartitionBy(it => new { it.Id, it.Name }).Take(1).Count();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
string oldOrderBy = this.OrderByValue;
|
string oldOrderBy = this.OrderByValue;
|
||||||
string externalOrderBy = oldOrderBy;
|
string externalOrderBy = oldOrderBy;
|
||||||
var isCount = this.IsCount;
|
var isCount = this.IsCount&&this.PartitionByValue.IsNullOrEmpty();
|
||||||
AppendFilter();
|
AppendFilter();
|
||||||
sql = new StringBuilder();
|
sql = new StringBuilder();
|
||||||
if (this.OrderByValue == null && (Skip != null || Take != null)) this.OrderByValue = " ORDER BY GetDate() ";
|
if (this.OrderByValue == null && (Skip != null || Take != null)) this.OrderByValue = " ORDER BY GetDate() ";
|
||||||
@ -239,7 +239,7 @@ namespace SqlSugar
|
|||||||
string orderByValue = (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null;
|
string orderByValue = (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null;
|
||||||
if (isCount) { orderByValue = null; }
|
if (isCount) { orderByValue = null; }
|
||||||
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, groupByValue, orderByValue);
|
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, groupByValue, orderByValue);
|
||||||
sql.Replace(UtilConstants.ReplaceKey, isRowNumber ? (this.IsCount ? null : rowNumberString) : null);
|
sql.Replace(UtilConstants.ReplaceKey, isRowNumber ? (isCount ? null : rowNumberString) : null);
|
||||||
if (isCount) { this.OrderByValue = oldOrderBy; return sql.ToString(); }
|
if (isCount) { this.OrderByValue = oldOrderBy; return sql.ToString(); }
|
||||||
var result = ToPageSql(sql.ToString(), this.Take, this.Skip);
|
var result = ToPageSql(sql.ToString(), this.Take, this.Skip);
|
||||||
if (ExternalPageIndex > 0)
|
if (ExternalPageIndex > 0)
|
||||||
@ -446,7 +446,7 @@ namespace SqlSugar
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (this.OrderByValue == null) return null;
|
if (this.OrderByValue == null) return null;
|
||||||
if (IsCount) return null;
|
if (IsCount&&this.PartitionByValue.IsNullOrEmpty()) return null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return this.OrderByValue;
|
return this.OrderByValue;
|
||||||
|
Loading…
Reference in New Issue
Block a user