mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update db.UpdateNav
This commit is contained in:
parent
ba684e7f4b
commit
34c106a11e
@ -8,7 +8,7 @@ namespace SqlSugar
|
||||
{
|
||||
public partial class UpdateNavProvider<Root, T> where T : class, new() where Root : class, new()
|
||||
{
|
||||
|
||||
public NavigateType? _NavigateType { get; set; }
|
||||
private void UpdateOneToMany<TChild>(string name, EntityColumnInfo nav) where TChild : class, new()
|
||||
{
|
||||
List<TChild> children = new List<TChild>();
|
||||
@ -34,15 +34,17 @@ namespace SqlSugar
|
||||
foreach (var child in childs)
|
||||
{
|
||||
thisFkColumn.PropertyInfo.SetValue(child, parentValue, null);
|
||||
ids.Add(parentValue);
|
||||
}
|
||||
children.AddRange(childs);
|
||||
}
|
||||
ids.Add(parentValue);
|
||||
}
|
||||
this._Context.Deleteable<object>()
|
||||
.AS(thisEntity.DbTableName)
|
||||
.In(thisFkColumn.DbColumnName, ids.Distinct().ToList()).ExecuteCommand();
|
||||
_NavigateType = NavigateType.OneToMany;
|
||||
InsertDatas(children, thisPkColumn);
|
||||
_NavigateType = null;
|
||||
SetNewParent<TChild>(thisEntity, thisPkColumn);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,14 @@ namespace SqlSugar
|
||||
Check.ExceptionEasy(pkColumn == null && NavColumn == null, $"The entity is invalid", $"实体错误无法使用导航");
|
||||
x.AsUpdateable.ExecuteCommand();
|
||||
InitData(pkColumn, insertData);
|
||||
this._ParentList = insertData.Union(updateData).Cast<object>().ToList();
|
||||
if (_NavigateType == NavigateType.OneToMany)
|
||||
{
|
||||
this._ParentList = children.Cast<object>().ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._ParentList = insertData.Union(updateData).Cast<object>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitData<TChild>(EntityColumnInfo pkColumn, List<TChild> UpdateData) where TChild : class, new()
|
||||
|
Loading…
Reference in New Issue
Block a user