Edition 0 Updated to asp. Net core 0



Yüklə 11,82 Mb.
Pdf görüntüsü
səhifə234/288
tarix12.07.2023
ölçüsü11,82 Mb.
#136458
1   ...   230   231   232   233   234   235   236   237   ...   288
NET-Microservices-Architecture-for-Containerized-NET-Applications

Additional resources 

Introduction to Dependency Injection in ASP.NET Core
https://learn.microsoft.com/aspnet/core/fundamentals/dependency-injection
 

Autofac.
Official documentation. 
https://docs.autofac.org/en/latest/
 

Comparing ASP.NET Core IoC container service lifetimes with Autofac IoC container 
instance scopes - Cesar de la Torre.
https://devblogs.microsoft.com/cesardelatorre/comparing-asp-net-core-ioc-service-life-times-
and-autofac-ioc-instance-scopes/
 
Implement the Command and Command Handler patterns 
In the DI-through-constructor example shown in the previous section, the IoC container was injecting 
repositories through a constructor in a class. But exactly where were they injected? In a simple Web 
API (for example, the catalog microservice in eShopOnContainers), you inject them at the MVC 
controller
s’ level, in a controller constructor, as part of the request pipeline of ASP.NET Core. However, 
in the initial code of this section (the 
CreateOrderCommandHandler
 class from the Ordering.API 
service in eShopOnContainers), the injection of dependencies is done through the constructor of a 
particular command handler. Let us explain what a command handler is and why you would want to 
use it. 
The Command pattern is intrinsically related to the CQRS pattern that was introduced earlier in this 
guide. CQRS has two sides. The first area is queries, using simplified queries with the 
Dapper
 micro 
ORM, which was explained previously. The second area is commands, which are the starting point for 
transactions, and the input channel from outside the service. 
As shown in Figure 7-24, the pattern is based on accepting commands from the client-side
processing them based on the domain model rules, and finally persisting the states with transactions. 


273 
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns 
Figure 7-24. High-level v
iew of the commands or “transactional side” in a CQRS pattern
 
Figure 7-24 shows that the UI app sends a command through the API that gets to a 
CommandHandler

that depends on the Domain model and the Infrastructure, to update the database. 

Yüklə 11,82 Mb.

Dostları ilə paylaş:
1   ...   230   231   232   233   234   235   236   237   ...   288




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin