开发者

ctp5 poco, base table objects and domain models

to simplify my class/object reuse, I am wondering if I can do that.

public class InvoiceTbl
{
    public Guid InvoiceId {get; set;}
    ...
}

public class InvoiceLineTbl
{
    public Guid InvoiceId {get; set;}
    public Guid InvoiceLineId {get; set;}
    ...
}

public class InvoiceBaseContext: DbContext
{
    DbSet<InvoiceTbl> Invoices {get; 开发者_StackOverflowset;}
    DbSet<InvoiceLineTbl> InvoiceLines {get; set;}
}

public Invoice : InvoiceTbl
{
    public virtual ICollection<InvoiceLine> Lines {get; set;}
}
public InvoiceLine: InvoiceLineTbl
{
    public Invoice Header {get; set;}
}

public InvoiceContext : DbContext
{
     public DbSet<Invoice> Invoices {get; set;}
     public DbSet<InvoiceLine> InvoiceLines {get; set;}
}

My Main purpose here is reusing the classes with additional navigation properties, so that I can easily work with small models which have all the required objects in the model.

I tried implementing this but it is mostly interpreted as inheritance, and it started looking for a Discriminator column etc, so I am wondering if this is even possible without much workaround.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜