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

loresoft / MediatR.CommandQuery / 9307610999

30 May 2024 06:43PM CUT coverage: 57.741%. Remained the same
9307610999

Pull #513

github

web-flow
Merge e90664f48 into 7184530a4
Pull Request #513: Bump Microsoft.NET.Test.Sdk from 17.9.0 to 17.10.0

348 of 708 branches covered (49.15%)

Branch coverage included in aggregate %.

1032 of 1682 relevant lines covered (61.36%)

19.52 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