/// Read the present state // TOCONSIDER: you should probably be separating this out per CQRS and reading from a denormalized/cached set of projections public Task <View> Read(ClientId id) => _stream(id).Query(Render);
public static Target For(ClientId id) => Target.NewAggregateId("Aggregate", id.ToString());
/// Maps a ClientId to the Target that specifies the Stream in which the data for that client will be held public static Target For(ClientId id) => Target.NewAggregateId("Todos", id?.ToString() ?? "1");
/// Execute the specified command public Task <Unit> Execute(ClientId id, Command command) => _stream(id).Execute(command);
/// Load details for a single specific item public Task <View> TryGet(ClientId clientId, int id) => _stream(clientId).Query(s => { var i = s.Items.SingleOrDefault(x => x.Id == id); return(i == null ? null : Render(i)); });
// // READ // /// List all open items public Task <IEnumerable <View> > List(ClientId clientId) => _stream(clientId).Query(s => s.Items.Select(Render));
/// Maps a ClientId to the Target that specifies the Stream in which the data for that client will be held public static string For(ClientId id) => StreamNameModule.create("Todos", id?.ToString() ?? "1");
/// Maps a ClientId to the CatId that specifies the Stream in which the data for that client will be held static Target CategoryId(ClientId id) => Target.NewCatId("Todos", id?.ToString() ?? "1");
public static string For(ClientId id) => StreamNameModule.create("Aggregate", id.ToString());