I'm not quite sure how to solve this problem properly.
I have a class Appointment
and a class AppointmentSeries
with inheritance from Appointment
.
My database is set up code-first with TPH.
Now when I get the database, I want to get all rows with the type of Appointment
, without the AppointmentSeries
.
I tried using OfType<Appointment>()
but this also gets the AppointmentSeries
.
I read that I have to use abstract classes to get the correct behaviour, but I don't want to implement an abstract class so I have to implement the same properties in Appointment
and AppointmentSeries
. Or do I have to?
The other solution I found was to add .where(a => !(a is AppointmentSeries))
to every query. But this is ugly and I get the entire database and then exclude some rows.
Is there a better way to get only the Appointments or structure my classes to I can use OfType<Appointments>()
?
All the best
Canere