private IEventMap <ProjectionContext> BuildMapFrom(IEventMapBuilder <TProjection, string, ProjectionContext> mapBuilder) { return(mapBuilder.Build(new ProjectorMap <TProjection, string, ProjectionContext> { Create = async(key, context, projector, shouldOverride) => { var projection = new TProjection() { Id = key }; await projector(projection); store.Add(projection); }, Update = async(key, context, projector, createIfMissing) => { TProjection projection = store.GetRepository <TProjection>().Find(key); await projector(projection); store.Add(projection); }, Delete = (key, context) => { store.GetRepository <TProjection>().RemoveByKey(key); return Task.FromResult(true); }, Custom = (context, projector) => projector() })); }
private string GetCountryName(Guid countryCode) { var lookup = store.GetRepository <CountryLookup>().Find(countryCode.ToString()); return((lookup != null) ? lookup.Name : ""); }