Update Aop.DataChanges

This commit is contained in:
sunkaixuan
2024-06-21 13:00:17 +08:00
parent c51e838a5f
commit e1e61db355
2 changed files with 35 additions and 0 deletions

View File

@@ -292,6 +292,39 @@ namespace SqlSugar
} }
} }
private void DataChangesAop(T [] items)
{
var dataEvent = this.Context.CurrentConnectionConfig.AopEvents?.DataChangesExecuted;
if (dataEvent != null)
{
foreach (var item in items)
{
if (item != null)
{
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.UpdateByObject, 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.UpdateByObject, EntityValue = item, EntityColumnInfo = columnInfo });
}
}
}
}
}
}
private void CheckTranscodeing(bool checkIsJson = true) private void CheckTranscodeing(bool checkIsJson = true)
{ {
if (this.EntityInfo.Columns.Any(it => it.IsTranscoding)) if (this.EntityInfo.Columns.Any(it => it.IsTranscoding))

View File

@@ -134,6 +134,7 @@ namespace SqlSugar
} }
} }
After(sql); After(sql);
DataChangesAop(this.UpdateObjs);
return result; return result;
} }
public bool ExecuteCommandHasChange() public bool ExecuteCommandHasChange()
@@ -184,6 +185,7 @@ namespace SqlSugar
} }
var result = await this.Ado.ExecuteCommandAsync(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray()); var result = await this.Ado.ExecuteCommandAsync(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
After(sql); After(sql);
DataChangesAop(this.UpdateObjs);
return result; return result;
} }
public Task<bool> ExecuteCommandHasChangeAsync(CancellationToken token) public Task<bool> ExecuteCommandHasChangeAsync(CancellationToken token)