Пример #1
0
 private static void StoreSnapshot(IDocumentSession session, IAggregateRoot root)
 {
    root.CurrentVersion = root.OriginalVersion+1;
    var instance = new Event
                      {
                         EntityId = root.Id,
                         Version = root.CurrentVersion,
                         IsSnapshot = true,
                         Data = root
                      };        
    session.Store(instance);         
 }
Пример #2
0
 private static void StoreEvents(ISession session, IAggregateRoot root)
 {
    int version = root.Version;
    foreach (object @event in root.Events)
    {
       version++;
       Event instance = new Event
                           {
                              EntityId = root.Id,
                              Version = version,
                              IsSnapshot = false,
                              Data = @event
                           };
       session.Save(instance);
    }
    root.Version = version;
    root.Events.Clear();
 }
Пример #3
0
 private static void StoreEvents(IDocumentSession session, IAggregateRoot root)
 {
    var version = root.OriginalVersion;
    foreach (var @event in root.Events)
    {
       version++;
       var instance = new Event
                           {
                              EntityId = root.Id,
                              Version = version,
                              IsSnapshot = false,
                              Data = @event
                           };
       session.Store(instance);
    }
    root.OriginalVersion = version;
    root.Events.Clear();
 }
Пример #4
0
 private static void StoreSnapshot(ISession session, IAggregateRoot root)
 {
    Event instance = new Event
                        {
                           EntityId = root.Id,
                           Version = root.Version,
                           IsSnapshot = true,
                           Data = root
                        };
    session.Save(instance);
 }