diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec index 8ae891c15..4764dcaf7 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/SqlSugar.MySqlConnectorCore.nuspec @@ -2,7 +2,7 @@ SqlSugar.MySqlConnectorCore - 5.9.1 + 5.9.5 sunkaixuan Landa http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs index 27e46656f..11ba8d413 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs @@ -53,6 +53,7 @@ namespace SqlSugar private UpdateNavProvider _ThenInclude(Expression> 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(name, nav); @@ -74,9 +76,9 @@ namespace SqlSugar } return GetResult(); } - private UpdateNavProvider _ThenInclude(Expression>> 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(name, nav); @@ -98,5 +101,20 @@ namespace SqlSugar } return GetResult(); } + 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(); + } + } + } + } } diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProviderHelper.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProviderHelper.cs index 5f5ca7d7a..a0c7ab1dc 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProviderHelper.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProviderHelper.cs @@ -18,10 +18,6 @@ namespace SqlSugar { if (_RootList == null) { - if (_Options != null && _Options.ManyToManyIsUpdateA) - { - this._Context.Updateable(_Roots).ExecuteCommand(); - } _RootList = _ParentList = _Roots.Cast().ToList(); _ParentEntity = this._Context.EntityMaintenance.GetEntityInfo(); } diff --git a/Src/Asp.NetCore2/SqlSugar/SqlSugarForCore.nuspec b/Src/Asp.NetCore2/SqlSugar/SqlSugarForCore.nuspec index 693f35d6a..4e3c251ad 100644 --- a/Src/Asp.NetCore2/SqlSugar/SqlSugarForCore.nuspec +++ b/Src/Asp.NetCore2/SqlSugar/SqlSugarForCore.nuspec @@ -2,7 +2,7 @@ SqlSugarCore - 5.0.9.6 + 5.0.9.7-preview02 sunkaixuan 果糖大数据科技 http://www.apache.org/licenses/LICENSE-2.0.html