The client API can be used to write one or more events to a stream atomically. This can be done either by appending the events to the stream in one operation, or by starting a transaction on the stream, writing events in one or more operations in that transaction, and then committing the transaction.
An optimistic concurrency check can be made during the write by specifying the version at which the stream is expected to be currently. Identical write operations are idempotent if the optimistic concurrency check is not disabled. More information on optimistic concurrency and idempotence can be found here.
Task<WriteResult> AppendToStreamAsync(string stream, long expectedVersion, IEnumerable<EventData> events)
Task<WriteResult> AppendToStreamAsync(string stream, long expectedVersion, params EventData events)
Task<EventStoreTransaction> StartTransactionAsync(string stream, long expectedVersion)
EventStoreTransaction ContinueTransaction(long transactionId)
Task WriteAsync(IEnumerable<EventData> events)
Task WriteAsync(params EventData events)
The writing methods all use a type named
EventData to represent an event to be stored. Instances of
EventData are immutable.
The Event Store does not have any built-in serialization, so the body and metadata for each event are represented in
EventData as a
The members on
||A unique identifier representing this event. This is used internally for idempotency if you write the same event twice you should use the same identifier both times.|
||The name of the event type. This can be used later for pattern matching in projections, so should be a “friendly” name rather than a CLR type name, for example.</code>|
||If the data and metadata fields are serialized as JSON, this should be set to true. Setting this to `true` will cause the projections framework to attempt to deserialize the data and metadata later.|
||The serialized data representing the event to be stored.|
||The serialized data representing metadata about the event to be stored.|
AppendToStreamAsync method writes events atomically to the end of a stream, working in an async manner.
The parameters are:
||The name of the stream to which to append.|
||The version at which we currently expect the stream to be in order that an optimistic concurrency check can be performed. This should either be a positive integer, or one of the constants `ExpectedVersion.NoStream`, `ExpectedVersion.EmptyStream`, or to disable the check, `ExpectedVersion.Any`. See here for a broader discussion of this.|
||The events to append. There is also an overload of each method which takes the events as a `params` array.|
Event Store docs are hosted on GitHub. The repository is public and it’s open to issues and pull requests. Contributions, corrections and feedback are all welcome.