• 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/EntityDataContextHandlerBase.cs
1
using System.Diagnostics.CodeAnalysis;
2

3
using AutoMapper;
4
using AutoMapper.QueryableExtensions;
5

6
using MediatR.CommandQuery.Definitions;
7

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

11
namespace MediatR.CommandQuery.EntityFrameworkCore.Handlers;
12

13
public abstract class EntityDataContextHandlerBase<TContext, TEntity, TKey, TReadModel, TRequest, TResponse>
14
    : DataContextHandlerBase<TContext, TRequest, TResponse>
15
    where TContext : DbContext
16
    where TEntity : class, IHaveIdentifier<TKey>, new()
17
    where TRequest : IRequest<TResponse>
18
{
19
    protected EntityDataContextHandlerBase(ILoggerFactory loggerFactory, TContext dataContext, IMapper mapper)
20
        : base(loggerFactory, dataContext, mapper)
21✔
21
    {
22
    }
21✔
23

24
    protected virtual async Task<TReadModel> Read([NotNull] TKey key, CancellationToken cancellationToken = default)
25
    {
26
        if (key == null)
18!
27
            throw new ArgumentNullException(nameof(key));
×
28

29
        var model = await DataContext
18✔
30
            .Set<TEntity>()
18✔
31
            .AsNoTracking()
18✔
32
            .Where(p => Equals(p.Id, key))
18✔
33
            .ProjectTo<TReadModel>(Mapper.ConfigurationProvider)
18✔
34
            .FirstOrDefaultAsync(cancellationToken)
18✔
35
            .ConfigureAwait(false);
18✔
36

37
        return model!;
18✔
38
    }
18✔
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