mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Add ToChildList by ids
This commit is contained in:
@@ -244,7 +244,18 @@ namespace SqlSugar
|
|||||||
var list = this.ToList();
|
var list = this.ToList();
|
||||||
return GetChildList(parentIdExpression, pk, list, primaryKeyValue, isContainOneself);
|
return GetChildList(parentIdExpression, pk, list, primaryKeyValue, isContainOneself);
|
||||||
}
|
}
|
||||||
|
public List<T> ToChildList(Expression<Func<T, object>> parentIdExpression, object [] primaryKeyValues, bool isContainOneself = true)
|
||||||
|
{
|
||||||
|
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||||
|
var pk = GetTreeKey(entity);
|
||||||
|
var list = this.ToList();
|
||||||
|
List<T> result = new List<T>();
|
||||||
|
foreach (var item in primaryKeyValues)
|
||||||
|
{
|
||||||
|
result.AddRange(GetChildList(parentIdExpression, pk, list, item, isContainOneself));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public List<T> ToParentList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue)
|
public List<T> ToParentList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue)
|
||||||
{
|
{
|
||||||
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
|
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||||
|
@@ -675,7 +675,18 @@ ParameterT parameter)
|
|||||||
return GetChildList(parentIdExpression, pk, list, primaryKeyValue, isContainOneself);
|
return GetChildList(parentIdExpression, pk, list, primaryKeyValue, isContainOneself);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<T>> ToChildListAsync(Expression<Func<T, object>> parentIdExpression, object[] primaryKeyValues, bool isContainOneself = true)
|
||||||
|
{
|
||||||
|
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||||
|
var pk = GetTreeKey(entity);
|
||||||
|
var list =await this.ToListAsync();
|
||||||
|
List<T> result = new List<T>();
|
||||||
|
foreach (var item in primaryKeyValues)
|
||||||
|
{
|
||||||
|
result.AddRange(GetChildList(parentIdExpression, pk, list, item, isContainOneself));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public Task<int> IntoTableAsync<TableEntityType>(CancellationToken cancellationToken = default)
|
public Task<int> IntoTableAsync<TableEntityType>(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return IntoTableAsync(typeof(TableEntityType), cancellationToken);
|
return IntoTableAsync(typeof(TableEntityType), cancellationToken);
|
||||||
|
@@ -220,7 +220,9 @@ namespace SqlSugar
|
|||||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||||
string ToSqlString();
|
string ToSqlString();
|
||||||
List<T> ToChildList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue, bool isContainOneself = true);
|
List<T> ToChildList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue, bool isContainOneself = true);
|
||||||
|
List<T> ToChildList(Expression<Func<T, object>> parentIdExpression, object[] primaryKeyValues, bool isContainOneself = true);
|
||||||
Task<List<T>> ToChildListAsync(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue, bool isContainOneself = true);
|
Task<List<T>> ToChildListAsync(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue, bool isContainOneself = true);
|
||||||
|
Task<List<T>> ToChildListAsync(Expression<Func<T, object>> parentIdExpression, object[] primaryKeyValues, bool isContainOneself = true);
|
||||||
List<T> ToParentList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue);
|
List<T> ToParentList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue);
|
||||||
List<T> ToParentList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue, Expression<Func<T, bool>> parentWhereExpression);
|
List<T> ToParentList(Expression<Func<T, object>> parentIdExpression, object primaryKeyValue, Expression<Func<T, bool>> parentWhereExpression);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user