Browse Source

Update Query.Tree()

pull/32/head
sunkaixuan 2 years ago
parent
commit
db048c5aba
  1. 4
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs
  2. 4
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs

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

@ -335,12 +335,12 @@ namespace SqlSugar
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
var pk = GetTreeKey(entity);
var list = this.ToList();
return GetTreeRoot(childListExpression, parentIdExpression, pk, list, rootValue);
return GetTreeRoot(childListExpression, parentIdExpression, pk, list, rootValue)??new List<T>();
}
public List<T> ToTree(Expression<Func<T, IEnumerable<object>>> childListExpression, Expression<Func<T, object>> parentIdExpression, object rootValue, object[] childIds)
{
var list = this.ToList();
return TreeAndFilterIds(childListExpression, parentIdExpression, rootValue, childIds, ref list);
return TreeAndFilterIds(childListExpression, parentIdExpression, rootValue, childIds, ref list) ?? new List<T>();
}
public virtual DataTable ToDataTable()

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

@ -565,14 +565,14 @@ ParameterT parameter)
public async Task<List<T>> ToTreeAsync(Expression<Func<T, IEnumerable<object>>> childListExpression, Expression<Func<T, object>> parentIdExpression, object rootValue, object[] childIds)
{
var list = await this.ToListAsync();
return TreeAndFilterIds(childListExpression, parentIdExpression, rootValue, childIds, ref list);
return TreeAndFilterIds(childListExpression, parentIdExpression, rootValue, childIds, ref list) ?? new List<T>();
}
public async Task<List<T>> ToTreeAsync(Expression<Func<T, IEnumerable<object>>> childListExpression, Expression<Func<T, object>> parentIdExpression, object rootValue)
{
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
var pk = GetTreeKey(entity); ;
var list = await this.ToListAsync();
return GetTreeRoot(childListExpression, parentIdExpression, pk, list, rootValue);
return GetTreeRoot(childListExpression, parentIdExpression, pk, list, rootValue) ?? new List<T>();
}
public async Task<List<T>> ToParentListAsync(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue)
{

Loading…
Cancel
Save