Skip to content

Commit

Permalink
- 修复 #454 优化遗留的 bug,影响 Aop.AuditValue 事件;#521
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Nov 6, 2020
1 parent 5ad30cc commit a73e882
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
16 changes: 0 additions & 16 deletions FreeSql.DbContext/FreeSql.DbContext.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions FreeSql.Tests/FreeSql.Tests/Issues/521.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using System.Threading;
using Xunit;
Expand All @@ -17,6 +18,18 @@ public class _521
public void SelectTest()
{
IFreeSql fsql = g.sqlserver;

//fsql.Aop.AuditValue += (s, e) => {
// if (e.Column.CsType == typeof(long)
// && e.Property.GetCustomAttribute<SnowflakeAttribute>(false) != null
// && e.Value?.ToString() == "0")
// {
// e.Value = 1;
// }

//};


fsql.Delete<ts521>().Where("1=1").ExecuteAffrows();
fsql.Insert(new ts521 { ID = 1000000000000000001 }).ExecuteAffrows();

Expand All @@ -28,6 +41,7 @@ public void SelectTest()
class ts521
{
[Key]
[Snowflake]
public long ID { get; set; }

[Description("名字")]
Expand All @@ -44,5 +58,6 @@ class ts521
[Column(IsVersion = true, InsertValueSql = "1")]
public long Version { get; set; }
}
public class SnowflakeAttribute: Attribute { }
}
}
2 changes: 1 addition & 1 deletion FreeSql/Internal/CommonProvider/UpdateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public static void AuditDataValue(object sender, IEnumerable<T1> data, IFreeSql
changedDict.Add(col.Attribute.Name, true);
}
if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false)
col.SetValue(data, val = "");
col.SetValue(d, val = "");
}
}
}
Expand Down

0 comments on commit a73e882

Please sign in to comment.