Update ToParentList

This commit is contained in:
sunkaixuan
2022-06-15 14:35:08 +08:00
parent 1e927fe06f
commit fd7122b90c

View File

@@ -1278,16 +1278,16 @@ namespace SqlSugar
tableName = this.QueryBuilder.JoinQueryInfos.First().TableName;
}
}
var current = this.Context.Queryable<T>().AS(tableName).InSingle(primaryKeyValue);
var current = this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).InSingle(primaryKeyValue);
if (current != null)
{
result.Add(current);
object parentId = ParentInfo.PropertyInfo.GetValue(current,null);
int i = 0;
while (parentId!=null&&this.Context.Queryable<T>().AS(tableName).In(parentId).Any())
while (parentId!=null&&this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).In(parentId).Any())
{
Check.Exception(i > 100, ErrorMessage.GetThrowMessage("Dead cycle", "出现死循环或超出循环上限100检查最顶层的ParentId是否是null或者0"));
var parent = this.Context.Queryable<T>().AS(tableName).InSingle(parentId);
var parent = this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).InSingle(parentId);
result.Add(parent);
parentId= ParentInfo.PropertyInfo.GetValue(parent, null);
++i;
@@ -1316,7 +1316,7 @@ namespace SqlSugar
tableName = this.QueryBuilder.JoinQueryInfos.First().TableName;
}
}
var current = this.Context.Queryable<T>().AS(tableName).Where(new List<IConditionalModel>() {
var current = this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).Where(new List<IConditionalModel>() {
new ConditionalModel()
{
ConditionalType = ConditionalType.Equal,
@@ -1329,7 +1329,7 @@ namespace SqlSugar
result.Add(current);
object parentId = ParentInfo.PropertyInfo.GetValue(current, null);
int i = 0;
while (parentId != null && this.Context.Queryable<T>().AS(tableName).Where(new List<IConditionalModel>() {
while (parentId != null && this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).Where(new List<IConditionalModel>() {
new ConditionalModel()
{
ConditionalType = ConditionalType.Equal,
@@ -1339,7 +1339,7 @@ namespace SqlSugar
} }).Any())
{
Check.Exception(i > 100, ErrorMessage.GetThrowMessage("Dead cycle", "出现死循环或超出循环上限100检查最顶层的ParentId是否是null或者0"));
var parent = this.Context.Queryable<T>().AS(tableName).Where(new List<IConditionalModel>() {
var parent = this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).Where(new List<IConditionalModel>() {
new ConditionalModel()
{
ConditionalType = ConditionalType.Equal,
@@ -1380,16 +1380,16 @@ namespace SqlSugar
tableName = this.QueryBuilder.JoinQueryInfos.First().TableName;
}
}
var current =await this.Context.Queryable<T>().AS(tableName).InSingleAsync(primaryKeyValue);
var current =await this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).InSingleAsync(primaryKeyValue);
if (current != null)
{
result.Add(current);
object parentId = ParentInfo.PropertyInfo.GetValue(current, null);
int i = 0;
while (parentId != null &&await this.Context.Queryable<T>().AS(tableName).In(parentId).AnyAsync())
while (parentId != null &&await this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).In(parentId).AnyAsync())
{
Check.Exception(i > 100, ErrorMessage.GetThrowMessage("Dead cycle", "出现死循环或超出循环上限100检查最顶层的ParentId是否是null或者0"));
var parent =await this.Context.Queryable<T>().AS(tableName).InSingleAsync(parentId);
var parent =await this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).InSingleAsync(parentId);
result.Add(parent);
parentId = ParentInfo.PropertyInfo.GetValue(parent, null);
++i;
@@ -1417,7 +1417,7 @@ namespace SqlSugar
tableName = this.QueryBuilder.JoinQueryInfos.First().TableName;
}
}
var current = await this.Context.Queryable<T>().AS(tableName).Where(new List<IConditionalModel>() {
var current = await this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).Where(new List<IConditionalModel>() {
new ConditionalModel()
{
ConditionalType = ConditionalType.Equal,
@@ -1430,7 +1430,7 @@ namespace SqlSugar
result.Add(current);
object parentId = ParentInfo.PropertyInfo.GetValue(current, null);
int i = 0;
while (parentId != null && await this.Context.Queryable<T>().AS(tableName).Where(new List<IConditionalModel>() {
while (parentId != null && await this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).Where(new List<IConditionalModel>() {
new ConditionalModel()
{
ConditionalType = ConditionalType.Equal,
@@ -1440,7 +1440,7 @@ namespace SqlSugar
} }).AnyAsync())
{
Check.Exception(i > 100, ErrorMessage.GetThrowMessage("Dead cycle", "出现死循环或超出循环上限100检查最顶层的ParentId是否是null或者0"));
var parent = await this.Context.Queryable<T>().AS(tableName).Where(new List<IConditionalModel>() {
var parent = await this.Context.Queryable<T>().AS(tableName).Filter(null, this.QueryBuilder.IsDisabledGobalFilter).Where(new List<IConditionalModel>() {
new ConditionalModel()
{
ConditionalType = ConditionalType.Equal,