234
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
Notice that the only thing that the AddDomainEvent method is doing is adding an event to the list.
No event is dispatched yet, and no event handler is invoked yet.
You actually want to dispatch the events later on, when you commit the transaction to the database. If
you are using Entity Framework Core, that means in the SaveChanges
method of your EF DbContext,
as in the following code:
// EF Core DbContext
public
class
OrderingContext : DbContext, IUnitOfWork
{
// ...
Dostları ilə paylaş: