Rebuilding Projections
Projections can be completely rebuilt with the async daemon subsystem. Both inline and asynchronous projections can be rebuilt with the async daemon.
public class DistanceProjection: EventProjection
{
public DistanceProjection()
{
ProjectionName = "Distance";
}
// Create a new Distance document based on a Travel event
public Distance Create(Travel travel, IEvent e)
{
return new Distance {Id = e.Id, Day = travel.Day, Total = travel.TotalDistance()};
}
}
StoreOptions(x => x.Projections.Add(new DistanceProjection(), ProjectionLifecycle.Async));
var agent = await StartDaemon();
// setup test data
await PublishSingleThreaded();
// rebuild projection `Distance`
await agent.RebuildProjection("Distance", CancellationToken.None);