Inheritance
LINQ to Entities supports three types of inheritance: Table Per Hierarchy (TPH) inheritance, Table Per Type (TPT) inheritance, and Table Per Concrete (TPC) inheritance. As table per concrete inheritance is not used as often as table per hierarchy and table per type inheritance, in this book we will only cover the first two inheritance types.
LINQ to Entities Table per Hierarchy inheritance
In Table per Hierarchy inheritance there is a single database table that contains fields for both parent information and child information. With relational data a discriminator column contains the value that determines which class any given record belongs to.
For example, consider a Persons
table that contains everyone employed by a company. Some people are employees and some are managers. The Persons
table contains a column named EmployeeType
that has a value of 1
for managers and a value of 2
for employees; this is the discriminator column.
In this scenario you can create a child entity of employees...