mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Add EnableDiffLogEvent
This commit is contained in:
parent
07c9f1d62a
commit
c70fd929e7
@ -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<Student>().EnableDiffLogEvent().ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ namespace SqlSugar
|
||||
public virtual Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
|
||||
protected virtual Func<string,string> FormatSql { get; set; }
|
||||
public virtual Action<Exception> ErrorEvent { get; set; }
|
||||
public virtual Action<DiffLogModel> DiffLogEvent { get; set; }
|
||||
public virtual List<IDbConnection> SlaveConnections { get; set; }
|
||||
public virtual IDbConnection MasterConnection { get; set; }
|
||||
#endregion
|
||||
|
@ -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<T> EnableDiffLogEvent() {
|
||||
|
||||
this.IsEnableDiffLogEvent = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false)
|
||||
{
|
||||
UpdateBuilder.IsOffIdentity = isOffIdentity;
|
||||
|
27
Src/Asp.Net/SqlSugar/Entities/DiffLogModel.cs
Normal file
27
Src/Asp.Net/SqlSugar/Entities/DiffLogModel.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class DiffLogModel
|
||||
{
|
||||
public List<DiffLogTableInfo> AfterDate { get; set; }
|
||||
public List<DiffLogTableInfo> 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<DiffLogColumnInfo> Columns { get; set; }
|
||||
}
|
||||
public class DiffLogColumnInfo {
|
||||
|
||||
public string ColumnName { get; set; }
|
||||
public string ColumnDescription { get; set; }
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ namespace SqlSugar
|
||||
Action<string, SugarParameter []> LogEventCompleted { get; set; }
|
||||
Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
|
||||
Action<Exception> ErrorEvent { get; set; }
|
||||
Action<DiffLogModel> DiffLogEvent { get; set; }
|
||||
bool IsClearParameters { get; set; }
|
||||
int CommandTimeOut { get; set; }
|
||||
TimeSpan SqlExecutionTime { get; }
|
||||
|
@ -46,6 +46,7 @@ namespace SqlSugar
|
||||
IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns);
|
||||
IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod);
|
||||
IUpdateable<T> IsEnableUpdateVersionValidation();
|
||||
IUpdateable<T> EnableDiffLogEvent();
|
||||
IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression);
|
||||
IUpdateable<T> RemoveDataCache();
|
||||
KeyValuePair<string,List<SugarParameter>> ToSql();
|
||||
|
@ -78,6 +78,7 @@
|
||||
<Compile Include="Entities\CacheKey.cs" />
|
||||
<Compile Include="Entities\ConditionalModel.cs" />
|
||||
<Compile Include="Entities\ConnMoreSettings.cs" />
|
||||
<Compile Include="Entities\DiffLogModel.cs" />
|
||||
<Compile Include="Entities\MapperCache.cs" />
|
||||
<Compile Include="Entities\SlaveConnectionConfig.cs" />
|
||||
<Compile Include="Enum\ConditionalType.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user