- 修复 ISelect.ToList(true) 无效的 bug;

- 增加 IAop.ConfigEntity 配置实体特性,可实现使用其他 ORM 的实体特性,#36;
This commit is contained in:
28810
2019-04-24 15:09:32 +08:00
parent b16218d779
commit e2d33e943f
10 changed files with 164 additions and 36 deletions

View File

@ -1,6 +1,6 @@
using FreeSql.DataAnnotations;
using FreeSql.Tests.DataContext.SqlServer;
using System;
using System.Linq;
using Xunit;
namespace FreeSql.Tests.DataAnnotations {
@ -9,6 +9,31 @@ namespace FreeSql.Tests.DataAnnotations {
public MySqlFluentTest() {
}
[Fact]
public void AopConfigEntity() {
g.mysql.CodeFirst.ConfigEntity<ModelAopConfigEntity>(a => a.Property(b => b.pkid).IsPrimary(true));
g.mysql.Aop.ConfigEntity = (s, e) => {
var attr = e.EntityType.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.Schema.TableAttribute), false).FirstOrDefault() as System.ComponentModel.DataAnnotations.Schema.TableAttribute;
if (attr != null) {
e.ModifyResult.Name = attr.Name;
}
};
g.mysql.Aop.ConfigEntityProperty = (s, e) => {
if (e.Property.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute), false).Any()) {
e.ModifyResult.IsPrimary = true;
}
};
var tsql1 = g.mysql.Select<ModelAopConfigEntity>().WhereDynamic(1).ToSql();
}
[System.ComponentModel.DataAnnotations.Schema.Table("xxx")]
class ModelAopConfigEntity {
[System.ComponentModel.DataAnnotations.Key]
[Column(IsPrimary = false)]
public int pkid { get; set; }
}
[Fact]
public void Fluent() {
g.mysql.CodeFirst