diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/FastestProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/FastestProvider.cs index 65f18f90b..12f49b17d 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/FastestProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/FastestProvider.cs @@ -299,6 +299,30 @@ namespace SqlSugar { this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuting($"Begin {title} name:{GetTableName()} ,count: {datas.Count},current time: {DateTime.Now} ", new SugarParameter[] { }); } + var dataEvent = this.context.CurrentConnectionConfig.AopEvents?.DataExecuting; + if (IsDataAop&&dataEvent!=null) + { + var entity = this.context.EntityMaintenance.GetEntityInfo(typeof(Type)); + foreach (var item in datas) + { + DataAop(item, isAdd + ? + DataFilterType.InsertByObject: + DataFilterType.UpdateByObject + , entity); + } + } + } + private void DataAop(Type item, DataFilterType type,EntityInfo entity) + { + var dataEvent = this.context.CurrentConnectionConfig.AopEvents?.DataExecuting; + if (dataEvent != null && item != null) + { + foreach (var columnInfo in entity.Columns) + { + dataEvent(columnInfo.PropertyInfo.GetValue(item, null), new DataFilterModel() { OperationType = type, EntityValue = item, EntityColumnInfo = columnInfo }); + } + } } #endregion diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/Setting.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/Setting.cs index bc339a8e7..11f515a75 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/Setting.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/FastestProvider/Setting.cs @@ -13,11 +13,17 @@ namespace SqlSugar private string CacheKey { get; set; } private string CacheKeyLike { get; set; } private string CharacterSet { get; set; } + private bool IsDataAop { get; set; } public IFastest SetCharacterSet(string CharacterSet) { this.CharacterSet = CharacterSet; return this; } + public IFastest EnableDataAop() + { + this.IsDataAop = true; + return this; + } public IFastest RemoveDataCache() { CacheKey = typeof(T).FullName; diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IFastest.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IFastest.cs index 7ca34cf1a..91b99412a 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IFastest.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IFastest.cs @@ -13,6 +13,7 @@ namespace SqlSugar IFastest AS(string tableName); IFastest PageSize(int Size); IFastest SetCharacterSet(string CharacterSet); + IFastest EnableDataAop(); int BulkCopy(List datas); Task BulkCopyAsync(List datas); int BulkCopy(string tableName,DataTable dataTable);