I am trying to implement a generic repository but I am snagged. Here is a summary of my object model. The problem is that the concrete repository, “UserAccountRepositoryStub” will not compile. The error is:
The type User has to be convertible to type IRepository…
IRepostory:
public interface IRepository<T> where T : IEntity
{
...
}
Abstract Repository:
public class AbstractRepository<T> where T : class, IEntity, IRepository<T> {...}
IUserAccountRepository:
public interface IUserAccountRepository
User:
public class User : IEntity{...}
UserRepositoryStub(concrete):
public class UserAccoutRepositoryStub : AbstractRepository<User>, IUserAccountRepository
The definition of
AbstractRepository<T>should probably bebecause you want the repository to implement
IRepository<T>not the objects in it, right?