diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToMany.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToMany.cs index 200e41dbd..4a3052162 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToMany.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavOneToMany.cs @@ -42,6 +42,10 @@ namespace SqlSugar children.AddRange(childs); } ids.Add(parentValue); + if (_Options?.OneToManyNoDeleteNull == true && childs == null) + { + ids.Remove(parentValue); + } } if (NotAny(name)) { diff --git a/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs b/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs index 331864007..954dbb606 100644 --- a/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs +++ b/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs @@ -49,6 +49,7 @@ namespace SqlSugar public bool ManyToManyEnableLogicDelete { get; set; } public bool OneToManyDeleteAll { get; set; } public bool OneToManyEnableLogicDelete { get; set; } + public bool OneToManyNoDeleteNull { get; set; } public Expression RootFunc { get; set; } public Expression CurrentFunc { get; set; } }