I'm attempting to use Ninject to inject repositories into controllers of my MVC project.
public class HomeController : Controller
{
private readonly ICustomerRepository _customerRepository;
//
// GET: /Home/
public HomeController(ICustomerRepository customerRepository)
{
_customerRepository = customerRepository;
}
}
This all makes sense and is easy enough, but when the view gets more complicated and needs to display a master detail scenario, do I inject both repository interfaces in? Does that change if it gets 4 or 5 levels deep? (e.g. User picks customer, project, group, division, and then gets a list of people)
There were three things I came up with.
- Inject all the necessary repositories via the constructor.
- Create the concept of a super repository, or
- Create partial views and controllers for each of repositories.
Is there a best-practice on the pattern I should use for this? Any insight would be great.