Though both are correct but which of the following is the recommended way:
public class MyService(MyRepository ...) {
...
}
or
public class MyService() {
myRepository = CreateMyRepository();
}
protected MyRepository CreateMyRepository() {
...
}
The former would mean that that ought to be a public getter for the repository, which defeats the purpose of allowing only the service to control the repository.