private static IDomainEvent ParseDomainEventEntityToDomainEvent(DomainEventEntity domainEventEntity) { var domainEventType = Type.GetType(domainEventEntity.FullyQualifiedEventTypeName); var domainEventObject = JsonConvert.DeserializeObject(domainEventEntity.EventData, domainEventType); return((IDomainEvent)domainEventObject); }
public void Store(IDomainEvent domainEvent) { var domainEventEntity = new DomainEventEntity { AggregateId = domainEvent.AggregateId, CorrelationId = domainEvent.CorrelationId, CreationDate = domainEvent.CreationDate, FullyQualifiedEventTypeName = domainEvent.GetType().AssemblyQualifiedName, EventData = JsonConvert.SerializeObject(domainEvent) }; _dbSet.Add(domainEventEntity); }
public async Task StoreAsync(IDomainEvent domainEvent) { var domainEventEntity = new DomainEventEntity { AggregateId = domainEvent.AggregateId, CorrelationId = domainEvent.CorrelationId, CreationDate = domainEvent.CreationDate, FullyQualifiedEventTypeName = domainEvent.GetType().AssemblyQualifiedName, EventData = JsonConvert.SerializeObject(domainEvent) }; _dbSet.Add(domainEventEntity); await _context.SaveChangesAsync(); }