Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Projections

Jon Sequeira edited this page Jan 11, 2015 · 3 revisions

Projections

Its.Cqrs has support for building read models (or projections) from the events in your event store. This is done using one or more event handler classes ("projectors"). The projector will be passed one event at a time and has the responsibility of updating a projection (for example in a database or cache) in response. Projectors are typically used both to replay historical events and to keep projections up to date as new events are written. Depending on your scenario, this process can be either:

  • synchronous when the events are first written, by subscribing projectors to an IEventBus where events are published after being successfully committed to the event store by an IEventSourcedRepository<T>, or

  • asynchronous by subscribing projectors to a ReadModelCatchup<T>, which polls the event store and calls the projectors with incoming events as they appear.

Its.Cqrs has a number of classes for creating projectors:

  • You can implement IUpdateProjectionWhen<T>. Using this interface, multiple handlers for different event types can be declared on the same class.

  • You can call Projector.Create<T> and create a handler for a single event type to create an anonymous instance of IUpdateProjectionWhen<T>.

  • You can call Projector.CreateFor<T> to create an anonymous duck-typed projector, which is not constrained to handle events of type IEvent. This can be useful in projects that create projections but have no need to reference your domain. (Projector.Create<T> and Projector.CreateFor<T> may be merged in the future #18.)

  • You can call Projector.CreateDynamic to create an anonymous projector that receives events as dynamic objects.

Clone this wiki locally