My presentation layer is in MVC 3.
I have a data access layer which returns repositories. Each repository is mapped to a single table.
For example, I have the following repository interfaces:
- ICustomerRepository
- ICustomerTypeRepository
I have Entity Framework implementations of these repositories. These implementations get injected at a runtime with Ninject.
I have two controllers:
- CustomerController
- CustomerTypeController
Each controller has a set of CRUD routines. Customer must have a type.
In order to create a customer record, I need to use EFCustomerTypeRepository.
I now have a constructor within a CustomerController which looks this:
public class CustomerController: Controller
{
private ICustomerRepository customerRepository;
private ICustomerTypeRepository customerTypeRepository;
public CustomerController(ICustomerRepository customerRepository,
ICustomerTypeRepository customerTypeRepository)
{
this.customerRepository = customerRepository;
this.customerTypeRepository = customerTypeRepository;
}
...
Development is in early phase, and if I take this approach, then within next few days this constructor will have 5 or more parameters. This doesn't look right.
I could store all this logic in EFCustomerRepository, however, this will break single responsibility principle. So I'm not going to do that.
Finally, I can wrap these repositories and pass a single RepositoryWrapper type object to my controller.
I don't want to introcude any more frameworks, tools than I have to. I'm aiming to achieve loose coupling and easy extensibility, but currently I'm stuck between passing more parameters to a constructor, or writing a wrapper for repositories.
I'm using MVC 3, EF 4.1, Ninject, Moq and Automapper. Thank you