mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
Update InsertNav tree
This commit is contained in:
@@ -41,18 +41,24 @@ namespace SqlSugar
|
||||
children.AddRange(childs);
|
||||
}
|
||||
}
|
||||
var isTreeChild = GetIsTreeChild(parentNavigateProperty, thisEntity);
|
||||
Check.ExceptionEasy(thisPkColumn == null, $"{thisEntity.EntityName}need primary key", $"实体{thisEntity.EntityName}需要主键");
|
||||
if (NotAny(name))
|
||||
if (NotAny(name) || isTreeChild)
|
||||
{
|
||||
InsertDatas(children, thisPkColumn);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
this._ParentList = children.Cast<object>().ToList();
|
||||
}
|
||||
SetNewParent<TChild>(thisEntity, thisPkColumn);
|
||||
}
|
||||
|
||||
private bool GetIsTreeChild(EntityColumnInfo parentNavigateProperty, EntityInfo thisEntity)
|
||||
{
|
||||
return this.NavContext?.Items?.Any() == true && parentNavigateProperty.PropertyInfo.PropertyType?.GenericTypeArguments?.FirstOrDefault() == thisEntity.Type;
|
||||
}
|
||||
|
||||
private static bool ParentIsPk(EntityColumnInfo parentNavigateProperty)
|
||||
{
|
||||
return parentNavigateProperty != null &&
|
||||
|
Reference in New Issue
Block a user