Exemplo n.º 1
0
        /// <summary>
        ///   Saves a snapshot of the specified event source.
        /// </summary>
        public void SaveShapShot(IEventSource source)
        {
            using (var ctx = new EventStoreContext())
            {
                IMemento memento = source.GetMemento();

                ctx.AddToSnapshots(new Snapshot
                {
                    Data        = ToBinary(converter.Convert(memento)),
                    AggregateId = source.Id,
                    Version     = source.Version,
                    Type        = memento.GetType().Name
                });

                ctx.SaveChanges();
            }
        }