- 增加 AuditValue ObjectAuditBreak 实现对象只触发一次审计事件;

This commit is contained in:
2881099 2022-08-17 17:01:38 +08:00
parent c43a90787c
commit 4829df9573
4 changed files with 13 additions and 0 deletions

View File

@ -347,6 +347,12 @@ namespace FreeSql.Aop
/// 实体对象 /// 实体对象
/// </summary> /// </summary>
public object Object { get; } public object Object { get; }
/// <summary>
/// 中断实体对象审计<para></para>
/// false: 每个实体对象的属性都会审计(默认)<para></para>
/// true: 每个实体对象只审计一次
/// </summary>
public bool ObjectAuditBreak { get; set; } = false;
} }
public enum AuditValueType { Update, Insert, InsertOrUpdate } public enum AuditValueType { Update, Insert, InsertOrUpdate }
#endregion #endregion

View File

@ -108,6 +108,8 @@ namespace FreeSql.Internal.CommonProvider
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false) if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
changedDict.Add(col.Attribute.Name, true); changedDict.Add(col.Attribute.Name, true);
} }
if (auditArgs.ObjectAuditBreak) break;
if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false) if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false)
col.SetValue(data, val = ""); col.SetValue(data, val = "");
} }

View File

@ -175,6 +175,7 @@ namespace FreeSql.Internal.CommonProvider
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false) if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
changedDict.Add(col.Attribute.Name, true); changedDict.Add(col.Attribute.Name, true);
} }
if (auditArgs.ObjectAuditBreak) break;
} }
if (col.Attribute.IsPrimary) if (col.Attribute.IsPrimary)
{ {

View File

@ -424,6 +424,8 @@ namespace FreeSql.Internal.CommonProvider
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false) if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
changedDict.Add(col.Attribute.Name, true); changedDict.Add(col.Attribute.Name, true);
} }
if (auditArgs.ObjectAuditBreak) break;
if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false) if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false)
col.SetValue(d, val = ""); col.SetValue(d, val = "");
} }
@ -446,6 +448,8 @@ namespace FreeSql.Internal.CommonProvider
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false) if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
changedDict.Add(col.Attribute.Name, true); changedDict.Add(col.Attribute.Name, true);
} }
if (auditArgs.ObjectAuditBreak) break;
if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false) if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false)
col.SetValue(data, val = ""); col.SetValue(data, val = "");
} }