mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 12:33:44 +08:00
db.Aop.DataChanges
This commit is contained in:
@@ -20,6 +20,7 @@ namespace SqlSugar
|
|||||||
public Action<string, SugarParameter[]> OnLogExecuted { set { this.Context.CurrentConnectionConfig.AopEvents.OnLogExecuted = value; } }
|
public Action<string, SugarParameter[]> OnLogExecuted { set { this.Context.CurrentConnectionConfig.AopEvents.OnLogExecuted = value; } }
|
||||||
public Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> OnExecutingChangeSql { set { this.Context.CurrentConnectionConfig.AopEvents.OnExecutingChangeSql = value; } }
|
public Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> OnExecutingChangeSql { set { this.Context.CurrentConnectionConfig.AopEvents.OnExecutingChangeSql = value; } }
|
||||||
public virtual Action<object, DataFilterModel> DataExecuting { set { this.Context.CurrentConnectionConfig.AopEvents.DataExecuting = value; } }
|
public virtual Action<object, DataFilterModel> DataExecuting { set { this.Context.CurrentConnectionConfig.AopEvents.DataExecuting = value; } }
|
||||||
|
public Action<object, DataFilterModel> DataChangesExecuted { set { this.Context.CurrentConnectionConfig.AopEvents.DataChangesExecuted = value; } }
|
||||||
public virtual Action<object, DataAfterModel> DataExecuted { set { this.Context.CurrentConnectionConfig.AopEvents.DataExecuted = value; } }
|
public virtual Action<object, DataAfterModel> DataExecuted { set { this.Context.CurrentConnectionConfig.AopEvents.DataExecuted = value; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -224,6 +224,40 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DataChangeAop(T [] items)
|
||||||
|
{
|
||||||
|
|
||||||
|
var dataEvent = this.Context.CurrentConnectionConfig.AopEvents?.DataChangesExecuted;
|
||||||
|
if (dataEvent != null)
|
||||||
|
{
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (item != null&& !(item is Dictionary<string,object>))
|
||||||
|
{
|
||||||
|
foreach (var columnInfo in this.EntityInfo.Columns)
|
||||||
|
{
|
||||||
|
if (columnInfo.ForOwnsOnePropertyInfo != null)
|
||||||
|
{
|
||||||
|
var data = columnInfo.ForOwnsOnePropertyInfo.GetValue(item, null);
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
dataEvent(columnInfo.PropertyInfo.GetValue(data, null), new DataFilterModel() { OperationType = DataFilterType.InsertByObject, EntityValue = item, EntityColumnInfo = columnInfo });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (columnInfo.PropertyInfo.Name == "Item" && columnInfo.IsIgnore)
|
||||||
|
{
|
||||||
|
//class index
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dataEvent(columnInfo.PropertyInfo.GetValue(item, null), new DataFilterModel() { OperationType = DataFilterType.InsertByObject, EntityValue = item, EntityColumnInfo = columnInfo });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetInsertItemByDic(int i, T item, List<DbColumnInfo> insertItem)
|
private void SetInsertItemByDic(int i, T item, List<DbColumnInfo> insertItem)
|
||||||
{
|
{
|
||||||
foreach (var column in (item as Dictionary<string, object>).OrderBy(it=>it.Key))
|
foreach (var column in (item as Dictionary<string, object>).OrderBy(it=>it.Key))
|
||||||
@@ -455,6 +489,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
this.RemoveCacheFunc();
|
this.RemoveCacheFunc();
|
||||||
}
|
}
|
||||||
|
DataChangeAop(this.InsertObjs);
|
||||||
}
|
}
|
||||||
protected void Before(string sql)
|
protected void Before(string sql)
|
||||||
{
|
{
|
||||||
|
@@ -92,6 +92,7 @@ namespace SqlSugar
|
|||||||
public Action<string, SugarParameter[]> OnLogExecuted { get; set; }
|
public Action<string, SugarParameter[]> OnLogExecuted { get; set; }
|
||||||
public Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> OnExecutingChangeSql { get; set; }
|
public Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> OnExecutingChangeSql { get; set; }
|
||||||
public Action<object, DataFilterModel> DataExecuting { get; set; }
|
public Action<object, DataFilterModel> DataExecuting { get; set; }
|
||||||
|
public Action<object, DataFilterModel> DataChangesExecuted { get; set; }
|
||||||
public Action<object, DataAfterModel> DataExecuted { get; set; }
|
public Action<object, DataAfterModel> DataExecuted { get; set; }
|
||||||
}
|
}
|
||||||
public class ConfigureExternalServices
|
public class ConfigureExternalServices
|
||||||
|
Reference in New Issue
Block a user