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

loresoft / FluentCommand / 5874771988

16 Aug 2023 04:44AM UTC coverage: 43.028% (+2.5%) from 40.495%
5874771988

push

github

web-flow
Merge pull request #277 from loresoft/feature/method-injectors

Feature/method injectors

765 of 2171 branches covered (35.24%)

Branch coverage included in aggregate %.

126 of 126 new or added lines in 6 files covered. (100.0%)

2361 of 5094 relevant lines covered (46.35%)

119.69 hits per line

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

0.0
/src/FluentCommand/Internal/DataSequentialReader.cs
1
using System.Data;
2

3
namespace FluentCommand.Internal;
4

5
public static class DataSequentialReader
6
{
7
    public static IEnumerable<TEntity> Query<TEntity>(IDataQuery dataQuery, Func<IDataRecord, TEntity> factory)
8
    {
9
        var results = new List<TEntity>();
×
10

11
        dataQuery.Read(reader =>
×
12
        {
×
13
            while (reader.Read())
×
14
            {
×
15
                var entity = factory(reader);
×
16
                results.Add(entity);
×
17
            }
×
18
        }, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult);
×
19

20
        return results;
×
21
    }
22

23
    public static TEntity QuerySingle<TEntity>(IDataQuery dataQuery, Func<IDataRecord, TEntity> factory)
24
    {
25
        TEntity result = default;
×
26

27
        dataQuery.Read(reader =>
×
28
        {
×
29
            if (reader.Read())
×
30
                result = factory(reader);
×
31
        }, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow);
×
32

33
        return result;
×
34

35
    }
36

37
    public static async Task<IEnumerable<TEntity>> QueryAsync<TEntity>(IDataQueryAsync dataQuery, Func<IDataRecord, TEntity> factory, CancellationToken cancellationToken = default)
38
    {
39
        var results = new List<TEntity>();
40

41
        await dataQuery.ReadAsync((reader, token) =>
42
        {
43
            while (reader.Read())
44
            {
45
                var entity = factory(reader);
46
                results.Add(entity);
47
            }
48
            return Task.CompletedTask;
49
        }, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult, cancellationToken);
50

51

52
        return results;
53
    }
54

55
    public static async Task<TEntity> QuerySingleAsync<TEntity>(IDataQueryAsync dataQuery, Func<IDataRecord, TEntity> factory, CancellationToken cancellationToken = default)
56
    {
57
        TEntity result = default;
58

59
        await dataQuery.ReadAsync((reader, token) =>
60
        {
61
            if (reader.Read())
62
                result = factory(reader);
63

64
            return Task.CompletedTask;
65
        }, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow, cancellationToken);
66

67
        return result;
68
    }
69

70
}
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