Base solution for your next web application
Open Closed

Entityframeowrk - Inheritance & .Include #1987


User avatar
0
maharatha created

Hi -

This question if more towards entityframework rather than AspnetZero, but I would like see if i can get some answers.

I have basically 4 tables , let's say A, B, C & D.

C inherits A -- C:A D inherits B -- D:B

A is the header table and B is the detail tables. So there is a foreign key relationship between A & B

var query2 = D.GetAll()
                .Include(p => p.B)
                .Include(p => p.A)
               .Include (p =>p.C)

I am able to access all properties of B & A but unable to access properties of C.

Any help would be appreciated


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Your case seems a bit complicated. Never tried such a relationship. It seems EF does not allow to join to the same hierarcy twice (B and C). If A is abstract, you could only include B. Or you can try to include C, "C.A" (instead of directly A) and B. I've no other idea.