So in a nutshell I have an abstract class :
public abstract class Member
{
public string PCode { get; set; }
public string Reference { get; set; }
public DateTime? ElectedDate { get; set; }
}
And this is inherited by 3 other classes:
public class Fellow : Member
{
// some class level properties here
}
public class ForeignMember : Member
{
// some class level properties here
}
public class HonoraryMember : Member
{
// some class level properties here
}
And the usual CRUD operations are done through using a generic repository pattern:
Interface
public interface ICRMRepository<T>
{
List<T> GetAll();
T GetById(int id);
T GetByPCode(string pcode);
}
Class
public class CRMRepository<T> : ICRMRepository<T> where T : class
{
public List<T> GetAll()
{
//actions go here
}
public T GetById(int id)
{
//actions go here
}
public T GetByPCode(string pcode)
{
//actions go here
}
}
The question is if I wanted to do a query that would bring back all the Fellows, HonoraryMembers and ForeignMembers in one result set, how would I do this?
Would it be better to have an interface instead of inheritance e.g. IMember, and then the three classes use that interface? Or some solution that uses both?