void OnDuplicateCommitButtonClick(object sender, EventArgs eventArgs) { Guid commitId = Guid.NewGuid(); var factory = container.Resolve <IEventSessionFactory>(); IEventSession session = factory.Create(); session.StoreEvent(new SourcedEvent { Body = new TestEvent() }, new EventStreamId("Test", "Test")); session.Commit(commitId); session.Commit(commitId); }
public void Save <TAggregateRoot>(TAggregateRoot aggregateRoot) where TAggregateRoot : AggregateRoot { using (IEventSession eventSession = eventSessionFactory.Create()) { foreach (SourcedEvent @event in aggregateRoot.EventsAdded) { EventStreamId eventStreamId = aggregateRoot.GetEventStreamId(); eventSession.StoreEvent(@event, eventStreamId); eventSession.StoreHeader(eventStreamId, EventOriginHeader.Key, EventOriginHeader.ForMachine(localMachine)); } eventSession.Commit(Guid.NewGuid()); } }
public static void StoreEventAndCommit <TEvent>(this IEventSession session, TEvent @event, EventStreamId id, ILocalMachine localMachine) where TEvent : new() { session.StoreEvent(@event, id, localMachine); session.Commit(Guid.NewGuid()); }
public void GivenICommitTheSessionWithTheId(Guid commitId) { session.Commit(commitId); }