private void Insert(TAggregate aggregateRoot) { var data = _jsonParser.AsJson(aggregateRoot.Snapshot()); var eventEntry = new PersitedObjectContainer(Guid.Parse(aggregateRoot.Identity), data, 1); Execute(con => { using (var tran = con.BeginTransaction()) { con.Execute($"insert into {_options.TableName} (Id,Data,Version) values ('{eventEntry.Id}','{eventEntry.Data}',{eventEntry.Version})", transaction: tran); HandleEventInsert(aggregateRoot, con, tran); tran.Commit(); } }); }
private void Insert(TAggregate aggregateRoot) { var data = _jsonParser.AsJson(aggregateRoot); var eventEntry = new PersitedObjectContainer(Guid.Parse(aggregateRoot.Identity), data, 1); Execute(con => { using (var tran = con.BeginTransaction()) { con.Execute($"insert into {_options.TableName} (Id,Data,Version) values ('{eventEntry.Id}','{eventEntry.Data}',{eventEntry.Version})", transaction: tran); foreach (var evnt in aggregateRoot.UncommittedChanges()) { //insert into events table in same transaction } tran.Commit(); } }); }
public static Event Serialize(VersionedDomainEvent evnt, string aggregateName) { var parser = new JsonParser <VersionedDomainEvent>(); return(new Event(evnt.AggregateRootId, evnt.OccuredOn, evnt.EventType, evnt.Version, aggregateName, parser.AsJson(evnt))); }
public static EventQueueItem Serialize(DomainEvent evnt, string aggregateName, Guid correlationId) { var parser = new JsonParser <DomainEvent>(); return(new EventQueueItem(evnt.AggregateRootId, evnt.OccuredOn, evnt.EventType, aggregateName, parser.AsJson(evnt), correlationId)); }