diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavManyToMany.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavManyToMany.cs index 6aca998eb..08be7eab4 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavManyToMany.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavManyToMany.cs @@ -31,7 +31,9 @@ namespace SqlSugar if (IsDeleteA()) { if (!_IsDeletedParant) - SetContext(() => this._Context.Deleteable(parentList).ExecuteCommand()); + SetContext(() => this._Context.Deleteable(parentList) + .EnableDiffLogEventIF(_RootOptions?.IsDiffLogEvent == true, _RootOptions?.DiffLogBizData) + .ExecuteCommand()); } var aids = _ParentList.Select(it => parentPkColumn.PropertyInfo.GetValue(it)).ToList(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToMany.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToMany.cs index 45a37af84..507b99441 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToMany.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToMany.cs @@ -25,7 +25,9 @@ namespace SqlSugar } if (!_IsDeletedParant) - SetContext(() => this._Context.Deleteable(prentList).ExecuteCommand()); + SetContext(() => this._Context.Deleteable(prentList) + .EnableDiffLogEventIF(_RootOptions?.IsDiffLogEvent==true,_RootOptions?.DiffLogBizData) + .ExecuteCommand()); var ids = _ParentList.Select(it => parentPkColumn.PropertyInfo.GetValue(it)).ToList(); var childList = GetChildList().In(thisFkColumn.DbColumnName, ids).ToList(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToOne.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToOne.cs index 6ed8868af..eeaee7684 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToOne.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavOneToOne.cs @@ -20,7 +20,9 @@ namespace SqlSugar if (!_IsDeletedParant) - SetContext(() => this._Context.Deleteable(parentList).ExecuteCommand()); + SetContext(() => this._Context.Deleteable(parentList) + .EnableDiffLogEventIF(_RootOptions?.IsDiffLogEvent == true, _RootOptions?.DiffLogBizData) + .ExecuteCommand()); var ids = _ParentList.Select(it => parentColumn.PropertyInfo.GetValue(it)).ToList(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs index fe543cf16..fc28ef8b2 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs @@ -16,6 +16,7 @@ namespace SqlSugar public EntityInfo _ParentEntity { get; set; } public EntityColumnInfo _ParentPkColumn { get; set; } public SqlSugarProvider _Context { get; set; } + internal DeleteNavRootOptions _RootOptions { get; set; } public bool _IsDeletedParant { get; set; } public List _WhereList = new List(); public List _Parameters = new List(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs index 299761810..17d6aa1cd 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs @@ -1153,6 +1153,25 @@ namespace SqlSugar { return DeleteNav(this.Queryable().Where(whereExpression).ToList()); } + + public DeleteNavTaskInit DeleteNav(T data, DeleteNavRootOptions options) where T : class, new() + { + return DeleteNav(new List() { data }, options); + } + public DeleteNavTaskInit DeleteNav(List datas, DeleteNavRootOptions options) where T : class, new() + { + var result = new DeleteNavTaskInit(); + result.deleteNavProvider = new DeleteNavProvider(); + result.deleteNavProvider._Roots = datas; + result.deleteNavProvider._Context = this; + result.deleteNavProvider._RootOptions = options; + return result; + } + public DeleteNavTaskInit DeleteNav(Expression> whereExpression, DeleteNavRootOptions options) where T : class, new() + { + return DeleteNav(this.Queryable().Where(whereExpression).ToList(),options); + } + public UpdateNavTaskInit UpdateNav(T data) where T : class, new() { return UpdateNav(new List() { data }); diff --git a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs index b4e42a5d0..2451db77f 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs @@ -769,6 +769,18 @@ namespace SqlSugar { return ScopedContext.DeleteNav(whereExpression); } + public DeleteNavTaskInit DeleteNav(T data, DeleteNavRootOptions options) where T : class, new() + { + return ScopedContext.DeleteNav(data, options); + } + public DeleteNavTaskInit DeleteNav(List datas, DeleteNavRootOptions options) where T : class, new() + { + return ScopedContext.DeleteNav(datas, options); + } + public DeleteNavTaskInit DeleteNav(Expression> whereExpression, DeleteNavRootOptions options) where T : class, new() + { + return ScopedContext.DeleteNav(whereExpression, options); + } public UpdateNavTaskInit UpdateNav(T data) where T : class, new() { return ScopedContext.UpdateNav(data); diff --git a/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs b/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs index 350074941..42aba04ab 100644 --- a/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs +++ b/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs @@ -12,6 +12,11 @@ namespace SqlSugar public bool ManyToManyIsDeleteA { get; set; } public bool ManyToManyIsDeleteB { get; set; } } + public class DeleteNavRootOptions + { + public bool IsDiffLogEvent { get; set; } + public object DiffLogBizData { get; set; } + } public class InsertNavRootOptions { public string[] IgnoreColumns { get; set; } diff --git a/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs b/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs index 1727e37c0..a7128df6d 100644 --- a/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs @@ -228,6 +228,9 @@ namespace SqlSugar DeleteNavTaskInit DeleteNav(T data) where T : class, new(); DeleteNavTaskInit DeleteNav(List datas) where T : class, new(); DeleteNavTaskInit DeleteNav(Expression> whereExpression) where T : class, new(); + DeleteNavTaskInit DeleteNav(T data, DeleteNavRootOptions options) where T : class, new(); + DeleteNavTaskInit DeleteNav(List datas, DeleteNavRootOptions options) where T : class, new(); + DeleteNavTaskInit DeleteNav(Expression> whereExpression, DeleteNavRootOptions options) where T : class, new(); UpdateNavTaskInit UpdateNav(T data) where T : class, new (); UpdateNavTaskInit UpdateNav(List datas) where T : class, new (); UpdateNavTaskInit UpdateNav(T data,UpdateNavRootOptions rootOptions) where T : class, new(); diff --git a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs index f81964e88..a62a915af 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs @@ -230,6 +230,20 @@ namespace SqlSugar { return this.Context.DeleteNav(whereExpression); } + + public DeleteNavTaskInit DeleteNav(T data, DeleteNavRootOptions options) where T : class, new() + { + return this.Context.DeleteNav(data, options); + } + public DeleteNavTaskInit DeleteNav(List datas, DeleteNavRootOptions options) where T : class, new() + { + return this.Context.DeleteNav(datas, options); + } + public DeleteNavTaskInit DeleteNav(Expression> whereExpression, DeleteNavRootOptions options) where T : class, new() + { + return this.Context.DeleteNav(whereExpression, options); + } + public UpdateNavTaskInit UpdateNav(T data) where T : class, new() { return this.Context.UpdateNav(data); diff --git a/Src/Asp.Net/SqlSugar/SqlSugarScope.cs b/Src/Asp.Net/SqlSugar/SqlSugarScope.cs index de9712f2e..5643fe893 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarScope.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarScope.cs @@ -815,6 +815,21 @@ namespace SqlSugar { return ScopedContext.DeleteNav(whereExpression); } + + + public DeleteNavTaskInit DeleteNav(T data, DeleteNavRootOptions options) where T : class, new() + { + return ScopedContext.DeleteNav(data, options); + } + public DeleteNavTaskInit DeleteNav(List datas, DeleteNavRootOptions options) where T : class, new() + { + return ScopedContext.DeleteNav(datas, options); + } + public DeleteNavTaskInit DeleteNav(Expression> whereExpression, DeleteNavRootOptions options) where T : class, new() + { + return ScopedContext.DeleteNav(whereExpression, options); + } + public UpdateNavTaskInit UpdateNav(T data) where T : class, new() { return ScopedContext.UpdateNav(data);