Ejemplo n.º 1
0
 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));
     }));
 }
Ejemplo n.º 2
0
        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);
            }));
        }
Ejemplo n.º 3
0
 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);
             }
         }
     }));
 }