mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-25 04:02:51 +08:00

- 增加 FreeSql.Provider.Odbc,实现 Oracle/SqlServer/MySql 的 Odbc 访问提供; - 增加 FreeSqlBuilder.UseConnectionString 参数 providerType,可解决因包版本冲突时,可能无法反射获得 FreeSql.Provider 对应的类型,通常这个参数不需要设置; - 优化 MaxLength 特性,当指定为 -1 时 DbType 会分别映射类型 text/nvarchar(max)/nvarchar2(4000);
41 lines
974 B
C#
41 lines
974 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using Xunit;
|
|
|
|
namespace FreeSql.Tests.Odbc.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);
|
|
}
|
|
}
|
|
}
|