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

loresoft / MediatR.CommandQuery / 11745720509

08 Nov 2024 04:20PM UTC coverage: 59.302% (-0.2%) from 59.479%
11745720509

push

github

pwelter34
fix analyzer issues

389 of 741 branches covered (52.5%)

Branch coverage included in aggregate %.

9 of 45 new or added lines in 13 files covered. (20.0%)

2 existing lines in 2 files now uncovered.

1208 of 1952 relevant lines covered (61.89%)

19.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
        ArgumentNullException.ThrowIfNull(request);
×
26

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

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

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

43
        return Mapper.Map<IList<TEntity>, IReadOnlyCollection<TReadModel>>(results);
×
44
    }
×
45
}
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

© 2026 Coveralls, Inc