269
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
dependencies are implemented in the services that a type needs and that you register in the IoC
container.
Typically, you want to inject dependencies that implement infrastructure objects. A typical
dependency to inject is a repository. But you could inject any other infrastructure dependency that
you may have. For simpler implementations, you could directly inject your Unit of Work pattern object
(the EF DbContext object), because the DBContext is also the implementation of your infrastructure
persistence objects.
In the following example, you can see how .NET is injecting the required repository objects through
the constructor. The class is a command handler, which will get covered in the next section.
Dostları ilə paylaş: