189
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
definitions query the database and return a dynamic ViewModel built on the fly for each query. Since
the queries are idempotent, they won’t change the data no matter how many times you run a query.
Therefore, you don’t need to be re
stricted by any DDD pattern used in the transactional side, like
aggregates and other patterns, and that is why queries are separated from the transactional area. You
query the database for the data that the UI needs and return a dynamic ViewModel that does not
need to be statically defined anywhere (no classes for the ViewModels) except in the SQL statements
themselves.
Since this approach is simple, the code required for the queries side (such as code using a micro ORM
like
Dapper
) can be implemented
within the same Web API project
. Figure 7-4 shows this approach.
The queries are defined in the
Dostları ilə paylaş: