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

模型是否支持继承 #612

Open
zcwcjj opened this issue Aug 31, 2023 · 1 comment
Open

模型是否支持继承 #612

zcwcjj opened this issue Aug 31, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@zcwcjj
Copy link

zcwcjj commented Aug 31, 2023

请问 模型是否支持继承,例如 company->list abstract employee 下面有2种类型 manager, worker,

@zcwcjj zcwcjj added the bug Something isn't working label Aug 31, 2023
@KVM-Explorer
Copy link

在6.4.7中我测试可以支持EF的TPT模式,也就是Company建表子表外键指向Company分别建立Manager和Worker,只需要在基类指定下Table的名称,并且在子类也指定Table名称就可以实现继承关系,然后DataContext分别构建DbSet。
如果只是抽象类而不需要建表的的话,指定Table一致或者不填写的话应该默认采用TPH模式,子类和父类在同一张表,可以参考看看FrameworkUser的实现过程

[Table("SpaceBasics")]
public class SpaceBasic : BasePoco
{
      [Display(Name = "名称")]
      public string Name { get; set; }
}
[Table("Seats")]
public class Seat : SpaceBasic
{
    
    
}
public DbSet<SpaceBasic> SpaceBasics { get; set; }
public DbSet<Seat> Seats { get; set; }
public DbSet<Area> Areas { get; set; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants