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

loresoft / MediatR.CommandQuery / 8410320720

24 Mar 2024 03:15PM CUT coverage: 58.562%. Remained the same
8410320720

push

github

pwelter34
Update EntityQueryEndpointBase.cs

230 of 438 branches covered (52.51%)

Branch coverage included in aggregate %.

560 of 911 relevant lines covered (61.47%)

19.53 hits per line

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

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

3
using Cosmos.Abstracts;
4

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

8
using Microsoft.Extensions.Logging;
9

10
namespace MediatR.CommandQuery.Cosmos.Handlers;
11

12
public class EntityIdentifierQueryHandler<TRepository, TEntity, TReadModel>
13
    : RepositoryHandlerBase<TRepository, TEntity, EntityIdentifierQuery<string, TReadModel>, TReadModel>
14
    where TRepository : ICosmosRepository<TEntity>
15
    where TEntity : class, IHaveIdentifier<string>, new()
16
{
17
    public EntityIdentifierQueryHandler(ILoggerFactory loggerFactory, TRepository repository, IMapper mapper) : base(loggerFactory, repository, mapper)
×
18
    {
19
    }
×
20

21
    protected override async Task<TReadModel> Process(EntityIdentifierQuery<string, TReadModel> request, CancellationToken cancellationToken)
22
    {
23
        if (request is null)
24
            throw new ArgumentNullException(nameof(request));
25
        if (!CosmosKey.TryDecode(request.Id, out var id, out var partitionKey))
26
            throw new InvalidOperationException("Invalid Cosmos Key format");
27

28
        var entity = await Repository
29
            .FindAsync(id, partitionKey, cancellationToken)
30
            .ConfigureAwait(false);
31

32
        // convert deleted entity to read model
33
        var model = Mapper.Map<TReadModel>(entity);
34

35
        return model;
36
    }
37
}
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