- 增加 Aop.AuditValue 事件,在插入/更新数据时审计属性值;

This commit is contained in:
28810
2019-08-25 18:13:02 +08:00
parent baa6c413a0
commit b57d35ae9b
12 changed files with 344 additions and 9 deletions

View File

@ -1,5 +1,6 @@
using FreeSql.DataAnnotations;
using FreeSql.DatabaseModel;
using FreeSql.Internal.Model;
using System;
using System.Collections.Generic;
using System.Data.Common;
@ -53,6 +54,11 @@ namespace FreeSql
/// CodeFirst迁移执行完成触发
/// </summary>
EventHandler<Aop.SyncStructureAfterEventArgs> SyncStructureAfter { get; set; }
/// <summary>
/// Insert/Update自动值处理, e.Column.SetMapValue(
/// </summary>
EventHandler<Aop.AuditValueEventArgs> AuditValue { get; set; }
}
}
@ -264,4 +270,43 @@ namespace FreeSql.Aop
/// </summary>
public long ElapsedMilliseconds => this.Stopwatch.ElapsedMilliseconds;
}
public class AuditValueEventArgs : EventArgs
{
public AuditValueEventArgs(AutoValueType autoValueType, ColumnInfo column, PropertyInfo property, object value)
{
this.AutoValueType = autoValueType;
this.Column = column;
this.Property = property;
this.Value = value;
}
/// <summary>
/// 类型
/// </summary>
public AutoValueType AutoValueType { get; }
/// <summary>
/// 属性列的元数据
/// </summary>
public ColumnInfo Column { get; }
/// <summary>
/// 反射的属性信息
/// </summary>
public PropertyInfo Property { get; }
/// <summary>
/// 获取实体的属性值,也可以设置实体的属性新值
/// </summary>
public object Value
{
get => _value;
set
{
_value = value;
this.IsChanged = true;
}
}
private object _value;
internal bool IsChanged { get; private set; }
}
public enum AutoValueType { Update, Insert }
}