Esempio n. 1
0
        private static readonly Guid StreamId = Guid.NewGuid(); // aggregate identifer

        #endregion Fields

        #region Methods

        private static void AppendToStream()
        {
            using (var stream = Store.OpenStream(StreamId, int.MinValue, int.MaxValue))
            {
                var @event = new SomeDomainEvent { Value = "Second event." };

                stream.Add(new EventMessage { Body = @event });
                stream.CommitChanges(Guid.NewGuid());
            }
        }
Esempio n. 2
0
        private static readonly Guid StreamId = Guid.NewGuid(); // aggregate identifer

        private static void AppendToStream()
        {
            using (var stream = Store.OpenStream(StreamId, int.MinValue, int.MaxValue))
            {
                var @event = new SomeDomainEvent { Value = "Second event." };

                stream.Add(new EventMessage { Body = @event });
                stream.CommitChanges(Guid.NewGuid());
            }
        }
Esempio n. 3
0
        private static void LoadFromSnapshotForwardAndAppend()
        {
            var latestSnapshot = Store.GetSnapshot(StreamId, int.MaxValue);

            using (var stream = Store.OpenStream(latestSnapshot, int.MaxValue))
            {
                var @event = new SomeDomainEvent { Value = "Third event (first one after a snapshot)." };

                stream.Add(new EventMessage { Body = @event });
                stream.CommitChanges(Guid.NewGuid());
            }
        }
Esempio n. 4
0
        private static void LoadFromSnapshotForwardAndAppend()
        {
            var latestSnapshot = Store.GetSnapshot(StreamId, int.MaxValue);

            using (var stream = Store.OpenStream(latestSnapshot, int.MaxValue))
            {
                var @event = new SomeDomainEvent { Value = "Third event (first one after a snapshot)." };

                stream.Add(new EventMessage { Body = @event });
                stream.CommitChanges(Guid.NewGuid());
            }
        }
Esempio n. 5
0
        private static void OpenOrCreateStream()
        {
            // we can call CreateStream(StreamId) if we know there isn't going to be any data.
            // or we can call OpenStream(StreamId, 0, int.MaxValue) to read all commits,
            // if no commits exist then it creates a new stream for us.
            using (var stream = store.OpenStream(StreamId, 0, int.MaxValue))
            {
                var @event = new SomeDomainEvent { Value = "Initial event." };

                stream.Add(new EventMessage { Body = @event });
                stream.CommitChanges(Guid.NewGuid());
            }
        }
Esempio n. 6
0
        private static void OpenOrCreateStream()
        {
            // we can call CreateStream(StreamId) if we know there isn't going to be any data.
            // or we can call OpenStream(StreamId, 0, int.MaxValue) to read all commits,
            // if no commits exist then it creates a new stream for us.
            using (var stream = Store.OpenStream(StreamId, 0, int.MaxValue))
            {
                var @event = new SomeDomainEvent { Value = "Initial event." };

                stream.Add(new EventMessage { Body = @event });
                stream.CommitChanges(Guid.NewGuid());
            }
        }