Browse Source

Optimized code

pull/40/head
sunkaixuan 1 year ago
parent
commit
2febf7c58d
  1. 44
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs

44
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs

@ -98,17 +98,17 @@ namespace SqlSugar
public virtual List<TResult> ToList<TResult>(Expression<Func<T, TResult>> expression)
{
if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
{
return NavSelectHelper.GetList(expression, this);
// var list = this.ToList().Select(expression.Compile()).ToList();
// return list;
}
else
{
//if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
//{
// return NavSelectHelper.GetList(expression, this);
// // var list = this.ToList().Select(expression.Compile()).ToList();
// // return list;
//}
//else
//{
var list = this.Select(expression).ToList();
return list;
}
//}
}
public virtual int Count()
@ -668,21 +668,21 @@ namespace SqlSugar
}
public virtual List<TResult> ToPageList<TResult>(int pageIndex, int pageSize, ref int totalNumber, Expression<Func<T, TResult>> expression)
{
if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
{
if (pageIndex == 0)
pageIndex = 1;
var list = this.Clone().Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(expression);
var countQueryable = this.Clone();
countQueryable.QueryBuilder.Includes = null;
totalNumber = countQueryable.Count();
return list;
}
else
{
//if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
//{
// if (pageIndex == 0)
// pageIndex = 1;
// var list = this.Clone().Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(expression);
// var countQueryable = this.Clone();
// countQueryable.QueryBuilder.Includes = null;
// totalNumber = countQueryable.Count();
// return list;
//}
//else
//{
var list = this.Select(expression).ToPageList(pageIndex, pageSize, ref totalNumber).ToList();
return list;
}
//}
}
public virtual List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber)
{

Loading…
Cancel
Save