Browse Source

Add Queryable.ToDataTableByEntityPage

pull/40/head
sunkaixuan 1 year ago
parent
commit
f2ab18a100
  1. 11
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs
  2. 11
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs
  3. 4
      Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

11
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs

@ -353,7 +353,11 @@ namespace SqlSugar
var list = this.ToList();
return TreeAndFilterIds(childListExpression, parentIdExpression, rootValue, childIds, ref list) ?? new List<T>();
}
public virtual DataTable ToDataTableByEntity()
{
var list = this.ToList();
return this.Context.Utilities.ListToDataTable(list);
}
public virtual DataTable ToDataTable()
{
QueryBuilder.ResultType = typeof(SugarCacheDataTable);
@ -392,6 +396,11 @@ namespace SqlSugar
}
return ToDataTable();
}
public DataTable ToDataTableByEntityPage(int pageNumber, int pageSize, ref int totalNumber)
{
var list=this.ToPageList(pageNumber, pageSize,ref totalNumber);
return this.Context.Utilities.ListToDataTable(list);
}
public virtual DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber)
{
_RestoreMapping = false;

11
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs

@ -350,7 +350,11 @@ namespace SqlSugar
this.Context.MappingTables = oldMapping;
return await this.Clone().ToJsonPageAsync(pageIndex, pageSize);
}
public async virtual Task<DataTable> ToDataTableByEntityAsync()
{
var list =await this.ToListAsync();
return this.Context.Utilities.ListToDataTable(list);
}
public async Task<DataTable> ToDataTableAsync()
{
QueryBuilder.ResultType = typeof(SugarCacheDataTable);
@ -381,6 +385,11 @@ namespace SqlSugar
this.Context.MappingTables = oldMapping;
return await this.Clone().ToDataTablePageAsync(pageIndex, pageSize);
}
public async Task<DataTable> ToDataTableByEntityPageAsync(int pageNumber, int pageSize, RefAsync<int> totalNumber)
{
var list =await this.ToPageListAsync(pageNumber, pageSize, totalNumber);
return this.Context.Utilities.ListToDataTable(list);
}
public async Task<List<T>> ToOffsetPageAsync(int pageIndex, int pageSize, RefAsync<int> totalNumber)
{
if (this.Context.CurrentConnectionConfig.DbType != DbType.SqlServer)

4
Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

@ -234,12 +234,16 @@ namespace SqlSugar
List<T> ToTree(Expression<Func<T, IEnumerable<object>>> childListExpression, Expression<Func<T, object>> parentIdExpression, object rootValue, object[] childIds);
Task<List<T>> ToTreeAsync(Expression<Func<T, IEnumerable<object>>> childListExpression, Expression<Func<T, object>> parentIdExpression, object rootValue, object[] childIds);
DataTable ToDataTable();
DataTable ToDataTableByEntity();
Task<DataTable> ToDataTableAsync();
Task<DataTable> ToDataTableByEntityAsync();
DataTable ToDataTablePage(int pageNumber, int pageSize);
Task<DataTable> ToDataTablePageAsync(int pageNumber, int pageSize);
DataTable ToDataTablePage(int pageNumber, int pageSize, ref int totalNumber);
DataTable ToDataTableByEntityPage(int pageNumber, int pageSize, ref int totalNumber);
DataTable ToDataTablePage(int pageNumber, int pageSize, ref int totalNumber,ref int totalPage);
Task<DataTable> ToDataTablePageAsync(int pageNumber, int pageSize, RefAsync<int> totalNumber);
Task<DataTable> ToDataTableByEntityPageAsync(int pageNumber, int pageSize, RefAsync<int> totalNumber);
List<T> ToOffsetPage(int pageNumber, int pageSize);
List<T> ToOffsetPage(int pageNumber, int pageSize,ref int totalNumber);

Loading…
Cancel
Save