public BaseSpec() { var builder = new BoundedContextModelBuilder(); builder.UseInMemoryBuses(); builder.UseInMemoryEventStore(); builder.Aggregate <FlightReservation>(cfg => { cfg .WithId(c => c.Localizer) .CreatedBy <CreateFlightReservation>() .Executes <CancelFlightReservation>(c => c.Localizer); }); builder.Projection <ReservationViewProjection>(cfg => { cfg .WithState(c => c.LastEventId) .AutoSubscribe(); }); builder.ReadModel <ReservationView, ReservationViewRepository>(cfg => { cfg.RespondsTo <SearchReservationsByFlight>(c => c.Query); }); Model = builder.Build(); CommandBus = Model.Services.GetRequiredService <ICommandBus>(); Host = new Hosting.HostProcess(Model); Host.Start(); }
public void Configure(BoundedContextModelBuilder builder) { var mongo = Config["Mongo"]; var sql = Config["SqlServer"]; builder.WithSqlServerEventStore(sql); builder.Projection( svcs => new PassengerList(mongo), cfg => { cfg .WithMongoState(mongo) .SubscribesTo <Events.PassengerCreated>(c => c.On) .RespondsTo <Queries.FindPassengerByEmail>(); }); }