I have one class called Requestparent.
I have 3 classes called requesttype1, requesttype2, requesttype3, all 3 inherit from RequestParent.
In one of the screens I need to make a query to show all opened requests of all types in a grid
something like:
Opened Date – Type – Opened by.
If I query the requestparent, I wont get the type.
Another solution would be to make 3 different queries to the child objects.
EF created a discriminator column automatically.
If you make a select query to a base type; then if creates join statements to the child tables and creates entities of child types.
Thus, even if you make a query to the base table, it creates entities of child types. You can just use
Entity.GetType()statement to get the type of the entity.For example, let’s say you have a base entity called Base and two derived entities called Derived1 and Derived2. Then if you run the following select statement;
You will have entities of type Derived 1 and Derived 2. Just employing oftype is enough to determine the type of the entity. For example;