Skip to content

The Event Serializer

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

In order to translate between your applicaiton event (implementing IEvent<TStreamId>) and your persisted event (implementing IPersistedEvent<TId, TStreamId>) there is an event serializer. The default implementation translates from (Type, object) to (string, byte[]) and back.

The DefaultEventSerializer<TStreamId, TEvent, TPersistedEvent> serializes the payload to JSON using Newtonsoft.Json, and then that string to a byte array using UTF8. To ensure it can deserialize again, it stores the payload type as a string using the event registry.

If you're not using the default configuration of persistent storage (e.g. not storing your event payload in a binary column in SQL Server) you'll want to override this, but for most usages, the default implementation will probably do just fine.