public async Task <IReadOnlyList <T> > SelectEntities <T>(ICollection <TEntityId> ids, ILoadEntityLogger logger, TContext context, Func <EntityWithId <TEntityId, TEntity>, T> selector) { return(await _chunkedExecutor.ExecuteAsync( new List <T>(), ids, async (chunk, transformedEntities) => { var entites = CacheOrClenaup(await _repository.Get(chunk, logger, context)); transformedEntities.AddRange(entites.Select(selector)); })); }
public async Task <IReadOnlyList <EntityWithId <WebResourceName, TEntity> > > Get(ICollection <WebResourceName> ids, ILoadEntityLogger logger, TContext context) { if (ids.Count == 0) { return new EntityWithId <WebResourceName, TEntity>[] { } } ; return(await _chunkedExecutor.ExecuteAsync( new List <EntityWithId <WebResourceName, TEntity> >(), ids, async (chunk, result) => { var entities = await GetInternal(chunk, logger); result.AddRange(entities); })); }
public async Task <IReadOnlyDictionary <TEntityId, T> > GetTransformedEntities <T>(ICollection <TEntityId> ids, ILoadEntityLogger logger, TContext context, Func <EntityWithId <TEntityId, TEntity>, T> transform) { return(await _chunkedExecutor.ExecuteAsync( new Dictionary <TEntityId, T>(_idComparer), ids, async (chunk, transformedEntities) => { var entites = CreateEnumerableWhichCachesOrCleansUp(await _repository.Get(chunk, logger, context)); foreach (var entity in entites) { if (!transformedEntities.ContainsKey(entity.Id)) { transformedEntities.Add(entity.Id, transform(entity)); } else { s_logger.WarnFormat("Entitiy '{0}' was contained multiple times in repository response. Ignoring redundant entity", entity.Id); } } })); }