19.11.2022 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Design a microservice domain model ........................................................................................................................ 198

The Domain Entity pattern ......................................................................................................................................... 199

Implement a microservice domain model with .NET ............................................................................................ 204

Domain model structure in a custom .NET Standard Library ....................................................................... 204

Structure aggregates in a custom .NET Standard library ............................................................................... 205

Implement domain entities as POCO classes ..................................................................................................... 206

Encapsulate data in the Domain Entities .............................................................................................................. 207

Seedwork (reusable base classes and interfaces for your domain model) .................................................. 210

The custom Entity base class ..................................................................................................................................... 211

Repository contracts (interfaces) in the domain model layer ...................................................................... 212

Additional resources ..................................................................................................................................................... 213

Implement value objects .................................................................................................................................................. 213

Important characteristics of value objects ........................................................................................................... 214

Value object implementation in C# ........................................................................................................................ 215

How to persist value objects in the database with EF Core 2.0 and later ................................................ 217

Persist value objects as owned entity types in EF Core 2.0 and later ........................................................ 218

Additional resources ..................................................................................................................................................... 221

Use enumeration classes instead of enum types ................................................................................................... 222

Implement an Enumeration base class .................................................................................................................. 222

Additional resources ..................................................................................................................................................... 223

Design validations in the domain model layer ....................................................................................................... 223

Implement validations in the domain model layer ........................................................................................... 224

Additional resources ..................................................................................................................................................... 226

Client-side validation (validation in the presentation layers) ............................................................................ 226

Additional resources ..................................................................................................................................................... 227

Domain events: design and implementation ........................................................................................................... 228

What is a domain event? ............................................................................................................................................. 228

Domain events versus integration events ............................................................................................................ 229

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

same domain ................................................................................................................................................................... 229

Implement domain events .......................................................................................................................................... 231

Conclusions on domain events ................................................................................................................................. 238

vi

Contents

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

Saved successfully!

Ooh no, something went wrong!