If I have a view that needs access to 5 different repositories, I am doing it right now:
public class MyClass { private readonly IRepo1 rep1; private readonly IRepo2 rep2; ... public MyClass(IRepo1 r1, IRepo2 r2, IRepo3 r3, IRepo4 r4...) { rep1 = r1; rep2 = r2; re3 = r3; } }
The problem with this approach is that the constructor is getting bigger and bigger, and if something changes in the constructor, I have to edit the changes completely through the system. How to avoid this problem?
I thought about creating a builder class that will be responsible for creating the repositories and analyze them in the views. Or is this a bad approach?
source share