IRepository with Inherited Classes
Posted
by
Stacey
on Stack Overflow
See other posts from Stack Overflow
or by Stacey
Published on 2011-01-03T13:47:09Z
Indexed on
2011/01/03
13:53 UTC
Read the original article
Hit count: 185
c#
|repository-pattern
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?
© Stack Overflow or respective owner