diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs index 150254380..57eaab3cc 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs @@ -132,35 +132,40 @@ namespace SqlSugar com(updateable); updateable.ExecuteCommand(); } - else if (IsFirst && _RootOptions != null) + else if (IsFirst && _RootOptions != null) { var isInsert = _RootOptions.IsInsertRoot; if (isInsert) { - var newRoots=new List(); + var newRoots = new List(); foreach (var item in _Roots) { var x = this._Context.Storageable(item).ToStorage(); if (x.InsertList.HasValue()) { - newRoots.Add( x.AsInsertable.ExecuteReturnEntity()); + newRoots.Add(x.AsInsertable.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent, _RootOptions.DiffLogBizData).ExecuteReturnEntity()); } - else + else { - x.AsUpdateable.ExecuteCommand(); + x.AsUpdateable.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent, _RootOptions.DiffLogBizData).ExecuteCommand(); newRoots.Add(item); } } - _ParentList=_RootList=newRoots.Cast().ToList(); + _ParentList = _RootList = newRoots.Cast().ToList(); } else { this._Context.Updateable(_Roots) + .EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent,_RootOptions.DiffLogBizData) .UpdateColumns(_RootOptions.UpdateColumns) .IgnoreColumns(_RootOptions.IgnoreColumns) .ExecuteCommand(); } } + else if (_RootOptions != null && _RootOptions?.IsDiffLogEvent == true) + { + this._Context.Updateable(_Roots).EnableDiffLogEvent(_RootOptions.DiffLogBizData).ExecuteCommand(); + } else { this._Context.Updateable(_Roots).ExecuteCommand(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index 8ade970de..d9ae4b6d5 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -499,7 +499,14 @@ namespace SqlSugar } - + public IInsertable EnableDiffLogEventIF(bool isDiffLogEvent, object diffLogBizData) + { + if (isDiffLogEvent) + { + return EnableDiffLogEvent(diffLogBizData); + } + return this; + } public IInsertable EnableDiffLogEvent(object businessData = null) { //Check.Exception(this.InsertObjs.HasValue() && this.InsertObjs.Count() > 1, "DiffLog does not support batch operations"); diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index b63a678dd..8452b4e51 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -198,6 +198,14 @@ namespace SqlSugar this.Context.MappingTables.Add(entityName, tableName); return this; ; } + public IUpdateable EnableDiffLogEventIF(bool isEnableDiffLog, object businessData = null) + { + if (isEnableDiffLog) + { + return EnableDiffLogEvent(businessData); + } + return this; + } public IUpdateable EnableDiffLogEvent(object businessData = null) { //Check.Exception(this.UpdateObjs.HasValue() && this.UpdateObjs.Count() > 1, "DiffLog does not support batch operations"); diff --git a/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs b/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs index 439671d61..2669fbe5d 100644 --- a/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs +++ b/Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs @@ -27,6 +27,8 @@ namespace SqlSugar public string IgnoreColumns { get; set; } public string[] UpdateColumns { get; set; } public bool IsInsertRoot { get; set; } + public bool IsDiffLogEvent { get; set; } + public object DiffLogBizData { get; set; } } public class UpdateNavOptions { diff --git a/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs b/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs index 03844dc66..55991ff20 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs @@ -92,6 +92,7 @@ namespace SqlSugar IUpdateable IsEnableUpdateVersionValidation(); IUpdateable EnableDiffLogEvent(object businessData = null); + IUpdateable EnableDiffLogEventIF(bool isEnableDiffLog,object businessData = null); IUpdateable ReSetValue(Action setValueExpression); IUpdateable RemoveDataCache(); IUpdateable RemoveDataCache(string likeString); diff --git a/Src/Asp.Net/SqlSugar/Interface/Insertable.cs b/Src/Asp.Net/SqlSugar/Interface/Insertable.cs index 118a93a06..e897e795e 100644 --- a/Src/Asp.Net/SqlSugar/Interface/Insertable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/Insertable.cs @@ -40,6 +40,7 @@ namespace SqlSugar IInsertable CallEntityMethod(Expression> method); IInsertable EnableDiffLogEvent(object businessData = null); + IInsertable EnableDiffLogEventIF(bool isDiffLogEvent, object businessData=null); IInsertable RemoveDataCache(); IInsertable RemoveDataCache(string likeString); KeyValuePair> ToSql();