mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 21:56:03 +08:00
Synchronization code
This commit is contained in:
parent
47637e9cc2
commit
3b5e5f3f34
@ -53,6 +53,7 @@ namespace SqlSugar
|
||||
|
||||
private UpdateNavProvider<Root, TChild> _ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new()
|
||||
{
|
||||
var isRoot = _RootList == null;
|
||||
InitParentList();
|
||||
var name = ExpressionTool.GetMemberName(expression);
|
||||
var nav = this._ParentEntity.Columns.FirstOrDefault(x => x.PropertyName == name);
|
||||
@ -60,6 +61,7 @@ namespace SqlSugar
|
||||
{
|
||||
Check.ExceptionEasy($"{name} no navigate attribute", $"{this._ParentEntity.EntityName}的属性{name}没有导航属性");
|
||||
}
|
||||
UpdateRoot(isRoot, nav);
|
||||
if (nav.Navigat.NavigatType == NavigateType.OneToOne || nav.Navigat.NavigatType == NavigateType.ManyToOne)
|
||||
{
|
||||
UpdateOneToOne<TChild>(name, nav);
|
||||
@ -74,9 +76,9 @@ namespace SqlSugar
|
||||
}
|
||||
return GetResult<TChild>();
|
||||
}
|
||||
|
||||
private UpdateNavProvider<Root, TChild> _ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
|
||||
{
|
||||
var isRoot = _RootList == null;
|
||||
InitParentList();
|
||||
var name = ExpressionTool.GetMemberName(expression);
|
||||
var nav = this._ParentEntity.Columns.FirstOrDefault(x => x.PropertyName == name);
|
||||
@ -84,6 +86,7 @@ namespace SqlSugar
|
||||
{
|
||||
Check.ExceptionEasy($"{name} no navigate attribute", $"{this._ParentEntity.EntityName}的属性{name}没有导航属性");
|
||||
}
|
||||
UpdateRoot(isRoot, nav);
|
||||
if (nav.Navigat.NavigatType == NavigateType.OneToOne || nav.Navigat.NavigatType == NavigateType.ManyToOne)
|
||||
{
|
||||
UpdateOneToOne<TChild>(name, nav);
|
||||
@ -98,5 +101,20 @@ namespace SqlSugar
|
||||
}
|
||||
return GetResult<TChild>();
|
||||
}
|
||||
private void UpdateRoot(bool isRoot, EntityColumnInfo nav)
|
||||
{
|
||||
if (isRoot && nav.Navigat.NavigatType != NavigateType.ManyToMany)
|
||||
{
|
||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Options != null && _Options.ManyToManyIsUpdateA)
|
||||
{
|
||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,6 @@ namespace SqlSugar
|
||||
{
|
||||
if (_RootList == null)
|
||||
{
|
||||
if (_Options != null && _Options.ManyToManyIsUpdateA)
|
||||
{
|
||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||
}
|
||||
_RootList = _ParentList = _Roots.Cast<object>().ToList();
|
||||
_ParentEntity = this._Context.EntityMaintenance.GetEntityInfo<Root>();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user