28810 dcf1da36d4 ## v0.9.18
- 增加 PostgreSQL 的 Odbc 访问提供,相比 FreeSql.Provider.PostgreSQL 支持的类型更少;
- 增加 通用的 Odbc 访问提供,不能迁移实体到数据库,不能 Skip 这样来分页,理论上能 crud 所有 odbc 数据库;
2019-09-21 00:48:34 +08:00

41 lines
972 B
C#

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Xunit;
namespace FreeSql.Tests.Odbc.Default
{
public class OdbcAopTest
{
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.odbc.Aop.AuditValue += audit;
g.odbc.Insert(item).ExecuteAffrows();
g.odbc.Aop.AuditValue -= audit;
Assert.Equal(item.createtime, date);
}
}
}