mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 修复 ISelect.ToList(true) 无效的 bug;
- 增加 IAop.ConfigEntity 配置实体特性,可实现使用其他 ORM 的实体特性,#36;
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user