/// <inheritdoc/> public void Commit() { _logger.Debug("Commit transaction for command {CommandType} with correlation {Correlation}", Command.Type, Command.CorrelationId); var trackedAggregateRoots = GetAggregateRootsBeingTracked(); _logger.Trace("Total number of objects tracked '{Count}", trackedAggregateRoots.Count()); foreach (var trackedAggregateRoot in trackedAggregateRoots) { _logger.Trace("Committing events from {TrackedAggregateRoot}", trackedAggregateRoot.GetType().AssemblyQualifiedName); var events = trackedAggregateRoot.UncommittedEvents; if (events.HasEvents) { _eventProcessingCompletion.Perform(Command.CorrelationId, events, () => { _logger.Trace("Events present - commit them to the event store"); _eventStore.CommitForAggregate(events).GetAwaiter().GetResult(); _logger.Trace("Commit object"); trackedAggregateRoot.Commit(); }).GetAwaiter().GetResult(); } } }