Ejemplo n.º 1
0
 public static void StoreEvent <TEvent>(this IEventSession session, TEvent @event, EventStreamId id, ILocalMachine localMachine)
     where TEvent : new()
 {
     session.StoreEvent(new SourcedEvent {
         Body = @event
     }, id);
     session.StoreHeader(id, EventOriginHeader.Key, EventOriginHeader.ForMachine(localMachine));
 }
Ejemplo n.º 2
0
        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());
            }
        }