We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用 SomeRepo.InsertAsync(obj) 插入新记录时,实际的 insert 语句执行了一次,但 AuditValue 会被执行两遍,导致字段值被重复处理。
SomeRepo.InsertAsync(obj)
AuditValue
下断点可以发现 第一次显示 AuditValueType 为 Insert
AuditValueType
Insert
第二次显示 AuditValueType 为 Update
Update
AuditValue 的代码:
// 使用 AuditValue 实现对带 [Aes] 的字段自动加密 fsql.Aop.AuditValue += (_, e) => { if (e.Column.CsType == typeof(string)) { var attr = e.Property.GetCustomAttribute<AesAttribute>(false); if (attr != null) { // 使用 base64 模拟加密过程 var newval= Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Value.ToString())); Log.Error("进行加密 {Name} {Old} {New}", attr.KeyName, e.Value, newval); e.Value = newval; } } };
打印的日志:
MySQL 5.7.23
.NET 8.0.101
The text was updated successfully, but these errors were encountered:
提供一个简易复现的demo
Sorry, something went wrong.
在 demo 里试了一下发现 AuditValue 还是被执行了两次,但是这回 insert 的语句中只使用了第一次处理后的值。
然后在原来的项目里重新尝试,虽然还是被执行了两次,也是只使用了第一次处理后的值
但是之前测试的时候 insert 语句里的值是被处理了两遍的。。。不过目前复现不出来了,可能是之前眼花了😂
No branches or pull requests
问题描述及重现代码:
使用
SomeRepo.InsertAsync(obj)
插入新记录时,实际的 insert 语句执行了一次,但AuditValue
会被执行两遍,导致字段值被重复处理。下断点可以发现
第一次显示
AuditValueType
为Insert
第二次显示
AuditValueType
为Update
AuditValue 的代码:
打印的日志:
数据库版本
MySQL 5.7.23
安装的Nuget包
.net framework/. net core? 及具体版本
.NET 8.0.101
The text was updated successfully, but these errors were encountered: