Say I have this interface:
public interface IRepository<T> where T : Entity
{
T Get(string query);
void Save(T entity);
}
And I have a couple of concrete classes like (where User and Project, of course, inherit from Entity):
public class UserRepository : IRepository<User> { ... }
public class ProjectRepository : IProjectRepository<Project> { ... }
What is the best way to keep a reference to all those in a single collection? You obviously can't have something like:
var repos = new IRepository<Entity>[]
{
new UserRepository(),
new ProjectRepository()
}
So must I have a non-generic interface from which the generic interface inherits?
public interface IRepository
{
Entity Get(string query);
void Save(Entity entity);
}
public interface IRepository<T> : IRepository { ... }
Thanks for any help, ideas, suggestions.