Add EnableDiffLogEvent

This commit is contained in:
sunkaixuan 2018-11-13 00:35:42 +08:00
parent 07c9f1d62a
commit c70fd929e7
7 changed files with 53 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -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

View File

@ -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;

View 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; }
}
}

View File

@ -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; }

View File

@ -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();

View File

@ -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" />