I am working on a project where I have a Reminders API.
My entities are made of two important properties : Frequency
and Type
.
Here is the base classes :
public abstract class ReminderDao
{
public int Id { get; set; }
public abstract ReminderFrequency Frequency { get; }
public abstract ReminderType Type { get; }
public string Title { get; set; }
public string Description { get; set; }
}
public abstract class OneTimeReminderDao : ReminderDao
{
public override ReminderFrequency Frequency => ReminderFrequency.OneTime;
// OneTime
public DateTimeOffset Date { get; set; }
}
public abstract class RecurringReminderDao : ReminderDao
{
public override ReminderFrequency Frequency => ReminderFrequency.Recurring;
// Recurring
public DateTimeOffset StartDate { get; set; }
public TimeSpan Interval { get; set; }
}
Here is the implementations:
public sealed class AppointmentOneTimeReminderDao : OneTimeReminderDao
{
public override ReminderType Type => ReminderType.Appointment;
}
public sealed class AppointmentRecurringReminderDao : RecurringReminderDao
{
public override ReminderType Type => ReminderType.Appointment;
}
I am stuck because I don’t know how to make a good TPH inheritance in order to get in a same table Reminders
the one time and the recurring reminders with typed reminders.
I am taking any advice ! Thanks a lot !