I have read several post on this subject, but the exact explanation eludes me.
As a caller, I need to pass in a repository that ideally should be passed as a parameter. There are interfaces for both RepositoryFactory and for myRepository. I am not using any entity framework:
var myRepositoryFactory = new RepositoryFactory<myRepository>();
var result = callSomeMethod(myRepositoryFactory);
Somewhere else:
public Result callSomeMethod(IRepositoryFactory<ImyRepository> myRepositoryFactory) {
using (var unitOfWork = unitOfWorkFactory.CreateUnitOfWork()) {
myRepository = myRepositoryFactory.CreateRepository(unitOfWork);
}
}
This is shortened (I would new up the class containing callSomeMethod and pass the factory to the constructor).
Issue is that IRepositoryFactory isn't able to accept myRepositoryFactory. ImyRepository is the troublesome part for me.