0

In the database, I have two tables PersonalDetails and Officers. There's one-to-many relationship between them.(One person can hold different positions in the same company at different periods). I'm using Entity Framework code first approach to communicate with the database. So far I had one entity called Officer that mapped to a join of the above two tables, But now that I have to perform CRUD operations on Officer this makes me have separate entities for them. Now the question is can I somehow leave the Officer entity as it is but instead of mapping to a view in the database have it descend from the two entities I will create and possibly be able insert/update it and have the changes reflected on the corresponding entities.

Here are the entities:(I've omitted the C# rules for a class definition for brevity )

 PersonDetails{Pin,FirstName,LastName}
 Officer{OfficerID,Pin,Position,ValidThru}

I will use these entities when I need to update/insert. But in user administration panel, I need to show combined information about users(or Officers).For instance:

Pin FirstName LastName Position ValidThru
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
  • possible duplicate of [Multiple Inheritance in C#](http://stackoverflow.com/questions/178333/multiple-inheritance-in-c-sharp) – t3chb0t Dec 19 '14 at 05:53
  • 1
    If you are using the technical definition of the word "descend", then no. It is possible to have an object which has properties of both, but a class can only have a single base class. – Mitch Dec 19 '14 at 07:15
  • I know that C# does not support multiple inheritance, that's why I did not use the term inherit. I'm rather looking for a possible feature of EF that would help what I need. – Mikayil Abdullayev Dec 19 '14 at 07:25
  • @MikeJM can we have these entity classes for example. I think there is misunderstanding regarding Descends/Multiple inheritance/Relationships. – Sarbanjeet Dec 19 '14 at 13:54

0 Answers0