I have a abstract generic class. I want to define a method inside there so I won’t have to do it in all derived classes.
Basically I need to fetch a repository class based on the Type the generic class will be.
I fetch the repoistories through another class which is non generic.
How can I let that class return a generic repository based on the type the generic caller has?
I was hoping for something like this.
public IRepository<T> Table<T>()
{
return _container.Resolve<IRepository<T>>();
}
If it would be a property it will be even better.
I don’t see the problem. You could write code like this that compiled. Does this not accomplish what you want?