IRepository with Inherited Classes
- by Stacey
In keeping with the Repository pattern of data input, I've a question in regards to using inherited classes. For instance, suppose I would have the class...
class Employee
IEmployeeRepository
{
Add(Employee employee);
}
This works fine, nothing wrong with it so far... but now let's say I continue on..
class Manager : Employee
Okay, now let's assume that I never need to enter a manager different than an Employee? What's the best approach here? Would a scenario such as ..
IEmployeeRepository
{
Add<T>(T employee) where T : Employee
}
Be the best approach, or do I need to abstract a different repository for each type?