Skip to content

Marten Inline List Projection

External Reference: Inline Projections

Use this to create list of items in the same transaction that the events are saved.

Requirements

The projection needs to be registered in the EventStoreOptions when the EventStore is being configured.

services.ConfigureMarten(options =>
{
options.Projections.Add<InlineProjection>(ProjectionLifecycle.Inline);
});

Pros

  • Simple to implement and to understand.
  • Database constraints can be used to enforce business rules.

Cons

  • Can be slow for the command processing
  • Cannot be upgraded after the fact has been saved.

Criteria

  • Use only for constrained fields like unique indexes, to make sure that publishing the event will not violate a global constraint.
  • Do not include fields other than the main index and the constrained fields.
  • Use when you can ensure that the projection will not change over time, and no bug fixes will be needed, which is in itself an unlikely scenario.

Examples