What problem does it solve?
This Skill helps build a Marten Single Stream Projection that materializes a single read model from one aggregate's event stream, enabling fast reads and simplified queries for a given aggregate.
Core Features & Use Cases
- Define the Projection Class: Create a {Resource}Projection class in src/BookStore.ApiService/Projections/ that inherits from SingleStreamProjection<T>, using the provided template at templates/Projection.cs.
- Register & Configure in Marten: Wire up the projection in Marten via the infrastructure configuration (e.g., options.Projections.Add<YourProjection>(ProjectionLifecycle.Async)) to optimize for performance.
- Indexing (Optional): Add a schema index for common query fields to improve read performance.
- Querying: Load the projection by stream ID or query on relevant fields to serve read-model data.
- Use Case: Build per-aggregate read models (e.g., AuthorDetails) from a single event stream to power fast UI reads or API endpoints.
Quick Start
Use the scaffold-single-stream-projection to generate an AuthorDetailsProjection, register it in Marten, and then query by the streamId to load the projection.