Skip to content

Commit a634192

Browse files
2881028810
authored andcommitted
- 优化 InsertOrUpdate AsType 使用错误的友好提示;
1 parent a9f9832 commit a634192

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/Internal/CommonProvider/InsertOrUpdateProvider.cs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,15 @@ public IInsertOrUpdate<T1> UpdateColumns(string[] columns)
7272
public static void AuditDataValue(object sender, IEnumerable<T1> data, IFreeSql orm, TableInfo table, Dictionary<string, bool> changedDict)
7373
{
7474
if (data?.Any() != true) return;
75-
if (orm.Aop.AuditValueHandler == null) return;
7675
foreach (var d in data)
77-
{
78-
if (d == null) continue;
79-
foreach (var col in table.Columns.Values)
80-
{
81-
object val = col.GetValue(d);
82-
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.InsertOrUpdate, col, table.Properties[col.CsName], val);
83-
orm.Aop.AuditValueHandler(sender, auditArgs);
84-
if (auditArgs.ValueIsChanged)
85-
{
86-
col.SetValue(d, val = auditArgs.Value);
87-
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
88-
changedDict.Add(col.Attribute.Name, true);
89-
}
90-
}
91-
}
76+
AuditDataValue(sender, d, orm, table, changedDict);
9277
}
9378
public static void AuditDataValue(object sender, T1 data, IFreeSql orm, TableInfo table, Dictionary<string, bool> changedDict)
9479
{
95-
if (orm.Aop.AuditValueHandler == null) return;
9680
if (data == null) return;
9781
if (typeof(T1) == typeof(object) && new[] { table.Type, table.TypeLazy }.Contains(data.GetType()) == false)
9882
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
83+
if (orm.Aop.AuditValueHandler == null) return;
9984
foreach (var col in table.Columns.Values)
10085
{
10186
object val = col.GetValue(data);

0 commit comments

Comments
 (0)