Example #1
0
 protected async void PostEvent(IGESEvent @event, Guid commitId, Dictionary<string, object> updateHeaders = null)
 {
     // standard data for metadata portion of persisted event
     var commitHeaders = new Dictionary<string, object>
     {
         // handy tracking id
         {CommitIdHeader, commitId},
         {CommandClrTypeHeader, @event.GetType().AssemblyQualifiedName}
     };
     // add extra data to metadata portion of presisted event
     commitHeaders = (updateHeaders ?? new Dictionary<string, object>())
         .Concat(commitHeaders)
         .GroupBy(d => d.Key)
         .ToDictionary(d => d.Key, d => d.First().Value);
     
     // process command so they fit the expectations of GES
     var commandToSave = new[] {ToEventData(Guid.NewGuid(), @event, commitHeaders)};
     // post to command stream
     await _eventStoreConnection.AppendToStreamAsync(EventStreamName, ExpectedVersion.Any, commandToSave);
 }
Example #2
0
        protected async void PostEvent(IGESEvent @event, Guid commitId, Dictionary <string, object> updateHeaders = null)
        {
            // standard data for metadata portion of persisted event
            var commitHeaders = new Dictionary <string, object>
            {
                // handy tracking id
                { CommitIdHeader, commitId },
                { CommandClrTypeHeader, @event.GetType().AssemblyQualifiedName }
            };

            // add extra data to metadata portion of presisted event
            commitHeaders = (updateHeaders ?? new Dictionary <string, object>())
                            .Concat(commitHeaders)
                            .GroupBy(d => d.Key)
                            .ToDictionary(d => d.Key, d => d.First().Value);

            // process command so they fit the expectations of GES
            var commandToSave = new[] { ToEventData(Guid.NewGuid(), @event, commitHeaders) };
            // post to command stream
            await _eventStoreConnection.AppendToStreamAsync(EventStreamName, ExpectedVersion.Any, commandToSave);
        }