Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aop.ConfigEntity 新功能 #36

Closed
2881099 opened this issue Apr 24, 2019 · 1 comment
Closed

Aop.ConfigEntity 新功能 #36

2881099 opened this issue Apr 24, 2019 · 1 comment

Comments

@2881099
Copy link
Collaborator

2881099 commented Apr 24, 2019

自定义特性

以下的示例代码,FreeSql 使用 EFCore 的实体特性。

fsql.CodeFirst.ConfigEntity<ModelAopConfigEntity>(a => a.Property(b => b.pkid).IsPrimary(true));

fsql.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;
};
fsql.Aop.ConfigEntityProperty = (s, e) => {
  if (e.Property.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute), false).Any())
    e.ModifyResult.IsPrimary = true;
};

[System.ComponentModel.DataAnnotations.Schema.Table("xxx")]
class ModelAopConfigEntity {
  [System.ComponentModel.DataAnnotations.Key]
  [Column(IsPrimary = false)]
  public int pkid { get; set; }
}
2881099 pushed a commit that referenced this issue Apr 24, 2019
- 增加 IAop.ConfigEntity 配置实体特性,可实现使用其他 ORM 的实体特性,#36
@pjy612
Copy link

pjy612 commented Apr 25, 2019

o( ̄▽ ̄)d大拇哥

@2881099 2881099 closed this as completed May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants