This commit is contained in:
sunkaixuan
2017-07-14 12:16:56 +08:00
parent 59e49827a5
commit c22046af68
3 changed files with 8 additions and 4 deletions

View File

@@ -132,7 +132,7 @@ namespace OrmTest.Demo
int count = 0; int count = 0;
var list4 = db.Queryable<Student>() var list4 = db.Queryable<Student>()
.PartitionBy(it => new { it.Name }).Take(1).ToPageList(3,3,ref count); .PartitionBy(it => new { it.Name }).Take(1).OrderBy(it=>it.Id).ToPageList(3,3,ref count);
//SqlFunc.AggregateSum(object thisValue) //SqlFunc.AggregateSum(object thisValue)
//SqlFunc.AggregateAvg<TResult>(TResult thisValue) //SqlFunc.AggregateAvg<TResult>(TResult thisValue)

View File

@@ -224,6 +224,7 @@ namespace SqlSugar
public virtual string ToSqlString() public virtual string ToSqlString()
{ {
string oldOrderBy = this.OrderByValue; string oldOrderBy = this.OrderByValue;
string externalOrderBy = oldOrderBy;
if (!IsDisabledGobalFilter && this.Context.QueryFilter.GeFilterList.IsValuable()) if (!IsDisabledGobalFilter && this.Context.QueryFilter.GeFilterList.IsValuable())
{ {
var gobalFilterList = this.Context.QueryFilter.GeFilterList.Where(it => it.FilterName.IsNullOrEmpty()).ToList(); var gobalFilterList = this.Context.QueryFilter.GeFilterList.Where(it => it.FilterName.IsNullOrEmpty()).ToList();
@@ -252,7 +253,10 @@ namespace SqlSugar
var result = ToPageSql(sql.ToString(), this.Take, this.Skip); var result = ToPageSql(sql.ToString(), this.Take, this.Skip);
if (ExternalPageIndex > 0) if (ExternalPageIndex > 0)
{ {
result = string.Format("SELECT *,ROW_NUMBER() OVER(ORDER BY GETDATE()) AS RowIndex2 FROM ({0}) ExternalTable ", result); if (externalOrderBy.IsNullOrEmpty()) {
externalOrderBy = " ORDER BY GetDate() ";
}
result = string.Format("SELECT *,ROW_NUMBER() OVER({0}) AS RowIndex2 FROM ({1}) ExternalTable ", externalOrderBy,result);
result = ToPageSql2(result,ExternalPageIndex, ExternalPageSize, true); result = ToPageSql2(result,ExternalPageIndex, ExternalPageSize, true);
} }
this.OrderByValue = oldOrderBy; this.OrderByValue = oldOrderBy;

View File

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.2.0.4")] [assembly: AssemblyVersion("4.2.0.6")]
[assembly: AssemblyFileVersion("4.2.0.4")] [assembly: AssemblyFileVersion("4.2.0.6")]