What is best way to map following classes?
I have classes where communication is “base” class as it contains shared data for either option. There can be only communication to ComSms or to ComEmail. The problem is i am unsure how to proceed with the mapping.
I would like if at all possible use one repository for accessing the Objects.
Class Set Up
public interface ICommunication
{
}
public Communication: ICommunication{
//PK and FK on this item
public virtual int CommunicationId{get;set;}
public virtual string Name {get;set;}
public virtual string Surname {get;set;}
public virtual DateTime Date{get;set;}
//I am expecting to switch on type between ComSms and ComEmail
public virtual Type {get;set;}
}
public ComSms : Communication{
public virtual string Number {get;set;}
public virtual string Text {get;set;}
}
public ComEmail : Communication{
public virtual string Subject{get;set;}
public virtual string Body {get;set;}
public virtual string Address {get;set;}
}
Database

Imagined usage
ICommunication smsToSave = new ComSms()
smsToSave.Name = "UserName";
smsToSave.Surname ="UserSurname";
smsToSave.Date = DateTime.Now;
smsToSave.Type = 1;
smsToSave.Number ="123456789";
smsToSave.Text = "Hello boys";
CommunicationRepository.Save(smsToSave)
ok
i have resolved it by separated repositories that handles ever part of it instead
i could not bind it correctly, so chosen to go around the problem.
if you find any way of doing this please let me know