NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Using Dapper as a micro ORM to per<strong>for</strong>m queries .......................................................................................... 182<br />
Dynamic versus static ViewModels ......................................................................................................................... 183<br />
Designing a DDD-oriented microservice................................................................................................................... 187<br />
Keep the microservice context boundaries relatively small .......................................................................... 187<br />
Layers in DDD microservices ..................................................................................................................................... 187<br />
Designing a microservice domain model ................................................................................................................. 192<br />
The Domain Entity pattern ......................................................................................................................................... 192<br />
Implementing a microservice domain model with .<strong>NET</strong> Core .......................................................................... 198<br />
Domain model structure in a custom .<strong>NET</strong> Standard Library ....................................................................... 198<br />
Structuring aggregates in a custom .<strong>NET</strong> Standard Library .......................................................................... 199<br />
Implementing domain entities as POCO classes ............................................................................................... 199<br />
Encapsulating data in the Domain Entities .......................................................................................................... 201<br />
Seedwork (reusable base classes and interfaces <strong>for</strong> your domain model) ............................................. 204<br />
Repository contracts (interfaces) in the domain model layer ...................................................................... 207<br />
Implementing value objects ...................................................................................................................................... 208<br />
Using Enumeration classes instead of C# language enum types ............................................................... 216<br />
Designing validations in the domain model layer ............................................................................................ 218<br />
Implementing validations in the domain model layer .................................................................................... 218<br />
Client-side validation (validation in the presentation layers) ....................................................................... 220<br />
Domain events: design and implementation........................................................................................................... 222<br />
What is a domain event? ............................................................................................................................................. 222<br />
Domain events versus integration events ............................................................................................................ 222<br />
Implementing domain events ........................................................................................................................................ 226<br />
Raising domain events ................................................................................................................................................. 226<br />
Single transaction across aggregates versus eventual consistency across aggregates ..................... 228<br />
The domain event dispatcher: mapping from events to event handlers ................................................. 230<br />
How to subscribe to domain events ....................................................................................................................... 231<br />
How to handle domain events.................................................................................................................................. 231<br />
Conclusions on domain events................................................................................................................................. 233<br />
Designing the infrastructure persistence layer ....................................................................................................... 234<br />
The Repository pattern ................................................................................................................................................ 234<br />
The Specification pattern ............................................................................................................................................ 238<br />
Implementing the infrastructure persistence layer with Entity Framework Core ...................................... 239<br />
Introduction to Entity Framework Core ................................................................................................................. 239<br />
Infrastructure in Entity Framework Core from a DDD perspective ............................................................. 239<br />
Implementing custom repositories with Entity Framework Core ............................................................... 242<br />
EF DbContext and IUnitOfWork instance lifetime in your IoC container ................................................. 244<br />
The repository instance lifetime in your IoC container ................................................................................... 245<br />
vi