mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 所有国产数据库支持 CustomMySql、CustomPostgreSQL、CustomOracle、CustomSqlServer 自定义适配;
This commit is contained in:
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.Custom.MySql
|
||||
{
|
||||
public class MySqlAopTest
|
||||
{
|
||||
|
||||
class TestAuditValue
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
[Now]
|
||||
public DateTime createtime { get; set; }
|
||||
}
|
||||
class NowAttribute: Attribute { }
|
||||
|
||||
[Fact]
|
||||
public void AuditValue()
|
||||
{
|
||||
var date = DateTime.Now.Date;
|
||||
var item = new TestAuditValue();
|
||||
|
||||
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
|
||||
{
|
||||
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
|
||||
e.Value = DateTime.Now.Date;
|
||||
};
|
||||
g.mysql.Aop.AuditValue += audit;
|
||||
|
||||
g.mysql.Insert(item).ExecuteAffrows();
|
||||
|
||||
g.mysql.Aop.AuditValue -= audit;
|
||||
|
||||
Assert.Equal(item.createtime, date);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user