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

loresoft / FluentCommand / 23278216331

19 Mar 2026 03:19AM UTC coverage: 57.398% (+0.7%) from 56.658%
23278216331

push

github

pwelter34
Enable nullable and improve source generators

1403 of 3069 branches covered (45.72%)

Branch coverage included in aggregate %.

527 of 907 new or added lines in 58 files covered. (58.1%)

22 existing lines in 10 files now uncovered.

4288 of 6846 relevant lines covered (62.64%)

330.58 hits per line

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

30.77
/src/FluentCommand/DataReaderExtensions.cs
1
using System.Data;
2
using System.Dynamic;
3

4
using FluentCommand.Reflection;
5

6
namespace FluentCommand;
7

8
/// <summary>
9
/// Extension methods for <see cref="IDataReader"/>
10
/// </summary>
11
public static class DataReaderExtensions
12
{
13
    /// <summary>
14
    /// A factory for creating TEntity objects from the current row in the <see cref="IDataReader" />.
15
    /// </summary>
16
    /// <typeparam name="TEntity">The type of the entity.</typeparam>
17
    /// <param name="reader">The open <see cref="IDataReader" /> to get the object from.</param>
18
    /// <returns>A TEntity object having property names set that match the field names in the <see cref="IDataReader" />.</returns>
19
    [Obsolete("Use generated data reader factory")]
20
    public static TEntity EntityFactory<TEntity>(this IDataReader reader)
21
        where TEntity : class, new()
22
    {
23
        var entityAccessor = TypeAccessor.GetAccessor<TEntity>();
×
24
        var entity = new TEntity();
×
25

26
        for (int i = 0; i < reader.FieldCount; i++)
×
27
        {
28
            if (reader.IsDBNull(i))
×
29
                continue;
30

31
            var name = reader.GetName(i);
×
32

33
            var memberAccessor = entityAccessor.FindColumn(name);
×
34
            if (memberAccessor == null)
×
35
                continue;
36

37
            var value = reader.GetValue(i);
×
38

39
            memberAccessor.SetValue(entity, value);
×
40
        }
41

42
        return entity;
×
43
    }
44

45
    /// <summary>
46
    /// A factory for creating dynamic objects from the current row in the <see cref="IDataReader" />.
47
    /// </summary>
48
    /// <param name="reader">The open <see cref="IDataReader" /> to get the object from.</param>
49
    /// <returns>A dynamic object having property names set that match the field names in the <see cref="IDataReader" />.</returns>
50
    public static dynamic DynamicFactory(IDataReader reader)
51
    {
52
        dynamic expando = new ExpandoObject();
126✔
53
        if (expando is not IDictionary<string, object?> dictionary)
126!
NEW
54
            return expando;
×
55

56
        for (int i = 0; i < reader.FieldCount; i++)
5,040✔
57
            dictionary.Add(reader.GetName(i), reader[i]);
2,394✔
58

59
        return expando;
126✔
60
    }
61
}
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