I am using the repository pattern found in the answer to this SO question:
Advantage of creating a generic repository vs. specific repository for each object?
Namely, each repository inherits from an abstract base class that contains generic methods like add, delete, etc. and also implements a specific repository interface for any methods that are unique to that repository/entity.
ie.
public class CompanyRepository : Repository<Company>, ICompanyRepository {
...
}
In my business layer I am using Structure Map to get an instance of the repository, but I am unsure how to use it.
// Structure Map initialisation
ObjectFactory.Initialize(
x =>
{
x.For<ICompanyRepository>().Use<CompanyRepository>();
});
resolving an instance:
return ObjectFactory.GetInstance<ICompanyRepository>();
However the instance I get is an interface and not the whole repository implementation. I don't have access to the methods on the base class (Repository<Company>
). What is the usual way to do this?