• 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

86.67
/src/MediatR.CommandQuery.EntityFrameworkCore/Handlers/EntityIdentifiersQueryHandler.cs
1
using AutoMapper;
2
using AutoMapper.QueryableExtensions;
3

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

7
using Microsoft.EntityFrameworkCore;
8
using Microsoft.Extensions.Logging;
9

10
namespace MediatR.CommandQuery.EntityFrameworkCore.Handlers;
11

12
public class EntityIdentifiersQueryHandler<TContext, TEntity, TKey, TReadModel>
13
    : EntityDataContextHandlerBase<TContext, TEntity, TKey, TReadModel, EntityIdentifiersQuery<TKey, TReadModel>, IReadOnlyCollection<TReadModel>>
14
    where TContext : DbContext
15
    where TEntity : class, IHaveIdentifier<TKey>, new()
16
{
17

18
    public EntityIdentifiersQueryHandler(ILoggerFactory loggerFactory, TContext dataContext, IMapper mapper)
19
        : base(loggerFactory, dataContext, mapper)
1✔
20
    {
21
    }
1✔
22

23

24
    protected override async Task<IReadOnlyCollection<TReadModel>> Process(EntityIdentifiersQuery<TKey, TReadModel> request, CancellationToken cancellationToken)
25
    {
26
        if (request is null)
1!
27
            throw new ArgumentNullException(nameof(request));
×
28

29
        var models = await DataContext
1✔
30
            .Set<TEntity>()
1✔
31
            .AsNoTracking()
1✔
32
            .Where(p => request.Ids.Contains(p.Id))
1✔
33
            .ProjectTo<TReadModel>(Mapper.ConfigurationProvider)
1✔
34
            .ToListAsync(cancellationToken)
1✔
35
            .ConfigureAwait(false);
1✔
36

37
        return models;
1✔
38
    }
1✔
39
}
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