Skip to content

Commit a73e882

Browse files
committed
- 修复 #454 优化遗留的 bug,影响 Aop.AuditValue 事件;#521
1 parent 5ad30cc commit a73e882

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
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.Tests/FreeSql.Tests/Issues/521.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.ComponentModel;
66
using System.ComponentModel.DataAnnotations;
77
using System.Diagnostics;
8+
using System.Reflection;
89
using System.Text;
910
using System.Threading;
1011
using Xunit;
@@ -17,6 +18,18 @@ public class _521
1718
public void SelectTest()
1819
{
1920
IFreeSql fsql = g.sqlserver;
21+
22+
//fsql.Aop.AuditValue += (s, e) => {
23+
// if (e.Column.CsType == typeof(long)
24+
// && e.Property.GetCustomAttribute<SnowflakeAttribute>(false) != null
25+
// && e.Value?.ToString() == "0")
26+
// {
27+
// e.Value = 1;
28+
// }
29+
30+
//};
31+
32+
2033
fsql.Delete<ts521>().Where("1=1").ExecuteAffrows();
2134
fsql.Insert(new ts521 { ID = 1000000000000000001 }).ExecuteAffrows();
2235

@@ -28,6 +41,7 @@ public void SelectTest()
2841
class ts521
2942
{
3043
[Key]
44+
[Snowflake]
3145
public long ID { get; set; }
3246

3347
[Description("名字")]
@@ -44,5 +58,6 @@ class ts521
4458
[Column(IsVersion = true, InsertValueSql = "1")]
4559
public long Version { get; set; }
4660
}
61+
public class SnowflakeAttribute: Attribute { }
4762
}
4863
}

FreeSql/Internal/CommonProvider/UpdateProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static void AuditDataValue(object sender, IEnumerable<T1> data, IFreeSql
374374
changedDict.Add(col.Attribute.Name, true);
375375
}
376376
if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false)
377-
col.SetValue(data, val = "");
377+
col.SetValue(d, val = "");
378378
}
379379
}
380380
}

0 commit comments

Comments
 (0)