• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / MediatR.CommandQuery / 8911801772

01 May 2024 04:09PM CUT coverage: 57.379% (-1.8%) from 59.163%
8911801772

push

github

pwelter34
tweak build

342 of 700 branches covered (48.86%)

Branch coverage included in aggregate %.

1011 of 1658 relevant lines covered (60.98%)

18.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/MediatR.CommandQuery.Cosmos/Handlers/EntityIdentifiersQueryHandler.cs
1
using AutoMapper;
2

3
using Cosmos.Abstracts;
4
using Cosmos.Abstracts.Extensions;
5

6
using MediatR.CommandQuery.Definitions;
7
using MediatR.CommandQuery.Queries;
8

9
using Microsoft.Azure.Cosmos;
10
using Microsoft.Extensions.Logging;
11

12
namespace MediatR.CommandQuery.Cosmos.Handlers;
13

14
public class EntityIdentifiersQueryHandler<TRepository, TEntity, TReadModel>
15
    : RepositoryHandlerBase<TRepository, TEntity, EntityIdentifiersQuery<string, TReadModel>, IReadOnlyCollection<TReadModel>>
16
    where TRepository : ICosmosRepository<TEntity>
17
    where TEntity : class, IHaveIdentifier<string>, new()
18
{
19
    public EntityIdentifiersQueryHandler(ILoggerFactory loggerFactory, TRepository repository, IMapper mapper) : base(loggerFactory, repository, mapper)
×
20
    {
21
    }
×
22

23
    protected override async Task<IReadOnlyCollection<TReadModel>> Process(EntityIdentifiersQuery<string, TReadModel> request, CancellationToken cancellationToken)
24
    {
25
        if (request is null)
×
26
            throw new System.ArgumentNullException(nameof(request));
×
27

28
        var keys = new HashSet<string>();
×
29
        foreach (var requestId in request.Ids)
×
30
        {
31
            if (CosmosKey.TryDecode(requestId, out var id, out PartitionKey partitionKey))
×
32
                keys.Add(id);
×
33
        }
34

35
        var query = await Repository
×
36
            .GetQueryableAsync()
×
37
            .ConfigureAwait(false);
×
38

39
        var results = await query
×
40
            .Where(p => keys.Contains(p.Id))
×
41
            .ToListAsync(cancellationToken)
×
42
            .ConfigureAwait(false);
×
43

44
        return Mapper.Map<IList<TEntity>, IReadOnlyCollection<TReadModel>>(results);
×
45
    }
×
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc