31.03.2020 Views

NET-Microservices-Architecture-for-Containerized-NET-Applications

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Additional resources ..................................................................................................................................................... 231

Domain events: design and implementation ........................................................................................................... 231

What is a domain event? ............................................................................................................................................. 232

Domain events versus integration events ............................................................................................................ 232

Domain events as a preferred way to trigger side effects across multiple aggregates within the

same domain ................................................................................................................................................................... 233

Implement domain events .......................................................................................................................................... 235

Conclusions on domain events ................................................................................................................................. 242

Additional resources ..................................................................................................................................................... 243

Design the infrastructure persistence layer .............................................................................................................. 243

The Repository pattern ................................................................................................................................................ 244

Additional resources ..................................................................................................................................................... 247

Implement the infrastructure persistence layer with Entity Framework Core ............................................ 248

Introduction to Entity Framework Core ................................................................................................................. 248

Infrastructure in Entity Framework Core from a DDD perspective ............................................................. 249

Implement custom repositories with Entity Framework Core ...................................................................... 250

EF DbContext and IUnitOfWork instance lifetime in your IoC container ................................................. 253

The repository instance lifetime in your IoC container ................................................................................... 254

Table mapping ................................................................................................................................................................ 254

Implement the Query Specification pattern ........................................................................................................ 257

Use NoSQL databases as a persistence infrastructure ......................................................................................... 260

Introduction to Azure Cosmos DB and the native Cosmos DB API ........................................................... 261

Implement .NET code targeting MongoDB and Azure Cosmos DB .......................................................... 263

Design the microservice application layer and Web API .................................................................................... 270

Use SOLID principles and Dependency Injection .............................................................................................. 270

Implement the microservice application layer using the Web API ................................................................. 271

Use Dependency Injection to inject infrastructure objects into your application layer ..................... 271

Implement the Command and Command Handler patterns ....................................................................... 275

The Command process pipeline: how to trigger a command handler ..................................................... 281

Implement the command process pipeline with a mediator pattern (MediatR) .................................. 284

Apply cross-cutting concerns when processing commands with the Behaviors in MediatR .......... 289

Implement resilient applications ....................................................................................... 294

vii

Contents

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!