Skip to content

Writing Events

Tomas Lycken edited this page Oct 30, 2017 · 2 revisions

In order to write events to the store, you take a dependency on the IEventStream interface, implemented by the event store, and use its Append method:

var event = SomeActionResultingInEvents(); // event is a list of your POCO events
await eventStream.Append(streamId, versionBeforeThisEvent, event);

The streamId is a way to shard the event list based on e.g. domain aggregates or features. The versionBeforeThisEvent is a long value included in the metadata of the last event you read from the store before you took the action, and is used for conflict detection (it must equal the highest version currently in the event store, for that stream).