diff --git a/Src/Asp.Net/SqlServerTest/Demos/9_Aop.cs b/Src/Asp.Net/SqlServerTest/Demos/9_Aop.cs index 2013a9f0b..37444e997 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/9_Aop.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/9_Aop.cs @@ -1,4 +1,5 @@ -using SqlSugar; +using OrmTest.Models; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -40,6 +41,19 @@ namespace OrmTest.Demo } + + + //diff log demo + + db.Ado.DiffLogEvent = it => + { + var editBeforeData = it.BeforeData; + var editAfterData = it.AfterDate; + var sql = it.Sql; + var parameter = it.Parameters; + }; + + db.Updateable().EnableDiffLogEvent().ExecuteCommand(); } } diff --git a/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs index 1ef2761b6..6451ebc8a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs @@ -60,6 +60,7 @@ namespace SqlSugar public virtual Func> ProcessingEventStartingSQL { get; set; } protected virtual Func FormatSql { get; set; } public virtual Action ErrorEvent { get; set; } + public virtual Action DiffLogEvent { get; set; } public virtual List SlaveConnections { get; set; } public virtual IDbConnection MasterConnection { get; set; } #endregion diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index e49733137..71f9ddaf6 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -26,6 +26,7 @@ namespace SqlSugar private bool IsVersionValidation { get; set; } public MappingTableList OldMappingTableList { get; set; } public bool IsAs { get; set; } + public bool IsEnableDiffLogEvent { get; set; } public virtual int ExecuteCommand() { PreToSql(); @@ -86,6 +87,12 @@ namespace SqlSugar return this; } + public IUpdateable EnableDiffLogEvent() { + + this.IsEnableDiffLogEvent = true; + return this; + } + public IUpdateable IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false) { UpdateBuilder.IsOffIdentity = isOffIdentity; diff --git a/Src/Asp.Net/SqlSugar/Entities/DiffLogModel.cs b/Src/Asp.Net/SqlSugar/Entities/DiffLogModel.cs new file mode 100644 index 000000000..576a344c3 --- /dev/null +++ b/Src/Asp.Net/SqlSugar/Entities/DiffLogModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SqlSugar +{ + public class DiffLogModel + { + public List AfterDate { get; set; } + public List BeforeData { get; set; } + public SugarParameter[] Parameters { get; set; } + public string Sql { get; set; } + public TimeSpan Time { get; set; } + } + public class DiffLogTableInfo + { + public string TableName { get; set; } + public string TableDescription { get; set; } + public List Columns { get; set; } + } + public class DiffLogColumnInfo { + + public string ColumnName { get; set; } + public string ColumnDescription { get; set; } + } +} diff --git a/Src/Asp.Net/SqlSugar/Interface/IAdo.cs b/Src/Asp.Net/SqlSugar/Interface/IAdo.cs index f0a8e9ec0..76fa547ce 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IAdo.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IAdo.cs @@ -27,6 +27,7 @@ namespace SqlSugar Action LogEventCompleted { get; set; } Func> ProcessingEventStartingSQL { get; set; } Action ErrorEvent { get; set; } + Action DiffLogEvent { get; set; } bool IsClearParameters { get; set; } int CommandTimeOut { get; set; } TimeSpan SqlExecutionTime { get; } diff --git a/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs b/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs index 38fdc133a..b71881c10 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs @@ -46,6 +46,7 @@ namespace SqlSugar IUpdateable IgnoreColumns(Expression> columns); IUpdateable IgnoreColumns(Func ignoreColumMethod); IUpdateable IsEnableUpdateVersionValidation(); + IUpdateable EnableDiffLogEvent(); IUpdateable ReSetValue(Expression> setValueExpression); IUpdateable RemoveDataCache(); KeyValuePair> ToSql(); diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.csproj b/Src/Asp.Net/SqlSugar/SqlSugar.csproj index 2fc62c5f4..4d63d644b 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.Net/SqlSugar/SqlSugar.csproj @@ -78,6 +78,7 @@ +