• 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

24.49
/src/FluentCommand.SqlServer/Merge/DataReaderWrapper.cs
1
using System.Data;
2

3
namespace FluentCommand.Merge;
4

5
/// <summary>
6
/// Wraps an <see cref="IDataReader"/> and optionally applies a prefix to field names when accessing data.
7
/// </summary>
8
public class DataReaderWrapper : IDataReader
9
{
10
    private readonly IDataReader _dataReader;
11
    private readonly string? _fieldPrefix;
12

13
    /// <summary>
14
    /// Initializes a new instance of the <see cref="DataReaderWrapper"/> class with the specified data reader.
15
    /// </summary>
16
    /// <param name="dataReader">The underlying <see cref="IDataReader"/> to wrap.</param>
17
    public DataReaderWrapper(IDataReader dataReader)
18
        : this(dataReader, null)
×
19
    {
20
    }
×
21

22
    /// <summary>
23
    /// Initializes a new instance of the <see cref="DataReaderWrapper"/> class with the specified data reader and field prefix.
24
    /// </summary>
25
    /// <param name="dataReader">The underlying <see cref="IDataReader"/> to wrap.</param>
26
    /// <param name="fieldPrefix">The prefix to apply to field names when accessing data, or <c>null</c> for no prefix.</param>
27
    public DataReaderWrapper(IDataReader dataReader, string? fieldPrefix)
4✔
28
    {
29
        _dataReader = dataReader;
4✔
30
        _fieldPrefix = fieldPrefix;
4✔
31
    }
4✔
32

33
    /// <summary>
34
    /// Gets the name of the field at the specified index.
35
    /// </summary>
36
    /// <param name="i">The zero-based index of the field.</param>
37
    /// <returns>The name of the field, or an empty string if there is no value to return.</returns>
38
    public string GetName(int i) => _dataReader.GetName(i);
×
39

40
    /// <summary>
41
    /// Gets the data type information for the specified field.
42
    /// </summary>
43
    /// <param name="i">The zero-based index of the field.</param>
44
    /// <returns>The data type information for the specified field.</returns>
45
    public string GetDataTypeName(int i) => _dataReader.GetDataTypeName(i);
×
46

47
    /// <summary>
48
    /// Gets the <see cref="Type"/> information corresponding to the type of <see cref="object"/> that would be returned from <see cref="GetValue(int)"/>.
49
    /// </summary>
50
    /// <param name="i">The zero-based index of the field.</param>
51
    /// <returns>The <see cref="Type"/> of the field value.</returns>
52
    public Type GetFieldType(int i) => _dataReader.GetFieldType(i);
1,200✔
53

54
    /// <summary>
55
    /// Gets the value of the specified field.
56
    /// </summary>
57
    /// <param name="i">The zero-based index of the field.</param>
58
    /// <returns>The value of the field as an <see cref="object"/>.</returns>
59
    public object GetValue(int i) => _dataReader.GetValue(i);
800✔
60

61
    /// <summary>
62
    /// Populates an array of objects with the column values of the current record.
63
    /// </summary>
64
    /// <param name="values">An array of <see cref="object"/> to copy the attribute fields into.</param>
65
    /// <returns>The number of objects in the array.</returns>
66
    public int GetValues(object[] values) => _dataReader.GetValues(values);
×
67

68
    /// <summary>
69
    /// Gets the index of the field with the specified name, applying the field prefix if set.
70
    /// </summary>
71
    /// <param name="name">The name of the field to find.</param>
72
    /// <returns>The zero-based index of the named field.</returns>
73
    public int GetOrdinal(string name)
74
    {
75
        string prefixName = _fieldPrefix != null
3,600!
76
            ? _fieldPrefix + name
3,600✔
77
            : name;
3,600✔
78

79
        return _dataReader.GetOrdinal(prefixName);
3,600✔
80
    }
81

82
    /// <summary>
83
    /// Gets the value of the specified column as a <see cref="bool"/>.
84
    /// </summary>
85
    /// <param name="i">The zero-based column ordinal.</param>
86
    /// <returns>The value of the column as a <see cref="bool"/>.</returns>
87
    public bool GetBoolean(int i) => _dataReader.GetBoolean(i);
×
88

89
    /// <summary>
90
    /// Gets the 8-bit unsigned integer value of the specified column.
91
    /// </summary>
92
    /// <param name="i">The zero-based column ordinal.</param>
93
    /// <returns>The 8-bit unsigned integer value of the specified column.</returns>
94
    public byte GetByte(int i) => _dataReader.GetByte(i);
×
95

96
    /// <summary>
97
    /// Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset.
98
    /// </summary>
99
    /// <param name="i">The zero-based column ordinal.</param>
100
    /// <param name="fieldOffset">The index within the field from which to start the read operation.</param>
101
    /// <param name="buffer">The buffer into which to read the stream of bytes.</param>
102
    /// <param name="bufferOffset">The index for buffer to start the read operation.</param>
103
    /// <param name="length">The number of bytes to read.</param>
104
    /// <returns>The actual number of bytes read.</returns>
105
    public long GetBytes(int i, long fieldOffset, byte[]? buffer, int bufferOffset, int length)
NEW
106
        => _dataReader.GetBytes(i, fieldOffset, buffer, bufferOffset, length);
×
107

108
    /// <summary>
109
    /// Gets the character value of the specified column.
110
    /// </summary>
111
    /// <param name="i">The zero-based column ordinal.</param>
112
    /// <returns>The character value of the specified column.</returns>
113
    public char GetChar(int i) => _dataReader.GetChar(i);
×
114

115
    /// <summary>
116
    /// Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset.
117
    /// </summary>
118
    /// <param name="i">The zero-based column ordinal.</param>
119
    /// <param name="fieldOffset">The index within the row from which to start the read operation.</param>
120
    /// <param name="buffer">The buffer into which to read the stream of characters.</param>
121
    /// <param name="bufferOffset">The index for buffer to start the read operation.</param>
122
    /// <param name="length">The number of characters to read.</param>
123
    /// <returns>The actual number of characters read.</returns>
124
    public long GetChars(int i, long fieldOffset, char[]? buffer, int bufferOffset, int length)
NEW
125
        => _dataReader.GetChars(i, fieldOffset, buffer, bufferOffset, length);
×
126

127
    /// <summary>
128
    /// Gets the <see cref="Guid"/> value of the specified field.
129
    /// </summary>
130
    /// <param name="i">The zero-based index of the field.</param>
131
    /// <returns>The <see cref="Guid"/> value of the specified field.</returns>
132
    public Guid GetGuid(int i) => _dataReader.GetGuid(i);
×
133

134
    /// <summary>
135
    /// Gets the 16-bit signed integer value of the specified field.
136
    /// </summary>
137
    /// <param name="i">The zero-based index of the field.</param>
138
    /// <returns>The 16-bit signed integer value of the specified field.</returns>
139
    public short GetInt16(int i) => _dataReader.GetInt16(i);
×
140

141
    /// <summary>
142
    /// Gets the 32-bit signed integer value of the specified field.
143
    /// </summary>
144
    /// <param name="i">The zero-based index of the field.</param>
145
    /// <returns>The 32-bit signed integer value of the specified field.</returns>
146
    public int GetInt32(int i) => _dataReader.GetInt32(i);
×
147

148
    /// <summary>
149
    /// Gets the 64-bit signed integer value of the specified field.
150
    /// </summary>
151
    /// <param name="i">The zero-based index of the field.</param>
152
    /// <returns>The 64-bit signed integer value of the specified field.</returns>
153
    public long GetInt64(int i) => _dataReader.GetInt64(i);
×
154

155
    /// <summary>
156
    /// Gets the single-precision floating point number of the specified field.
157
    /// </summary>
158
    /// <param name="i">The zero-based index of the field.</param>
159
    /// <returns>The single-precision floating point number of the specified field.</returns>
160
    public float GetFloat(int i) => _dataReader.GetFloat(i);
×
161

162
    /// <summary>
163
    /// Gets the double-precision floating point number of the specified field.
164
    /// </summary>
165
    /// <param name="i">The zero-based index of the field.</param>
166
    /// <returns>The double-precision floating point number of the specified field.</returns>
167
    public double GetDouble(int i) => _dataReader.GetDouble(i);
×
168

169
    /// <summary>
170
    /// Gets the string value of the specified field.
171
    /// </summary>
172
    /// <param name="i">The zero-based index of the field.</param>
173
    /// <returns>The string value of the specified field.</returns>
174
    public string GetString(int i) => _dataReader.GetString(i);
×
175

176
    /// <summary>
177
    /// Gets the fixed-position numeric value of the specified field.
178
    /// </summary>
179
    /// <param name="i">The zero-based index of the field.</param>
180
    /// <returns>The fixed-position numeric value of the specified field.</returns>
181
    public decimal GetDecimal(int i) => _dataReader.GetDecimal(i);
×
182

183
    /// <summary>
184
    /// Gets the date and time data value of the specified field.
185
    /// </summary>
186
    /// <param name="i">The zero-based index of the field.</param>
187
    /// <returns>The date and time data value of the specified field.</returns>
188
    public DateTime GetDateTime(int i) => _dataReader.GetDateTime(i);
×
189

190
    /// <summary>
191
    /// Returns an <see cref="IDataReader"/> for the specified column ordinal.
192
    /// </summary>
193
    /// <param name="i">The zero-based index of the field.</param>
194
    /// <returns>An <see cref="IDataReader"/> for the specified column ordinal.</returns>
195
    public IDataReader GetData(int i) => _dataReader.GetData(i);
×
196

197
    /// <summary>
198
    /// Determines whether the specified field is set to null.
199
    /// </summary>
200
    /// <param name="i">The zero-based index of the field.</param>
201
    /// <returns><c>true</c> if the specified field is set to null; otherwise, <c>false</c>.</returns>
202
    public bool IsDBNull(int i) => _dataReader.IsDBNull(i);
2,400✔
203

204
    /// <summary>
205
    /// Gets the number of columns in the current row.
206
    /// </summary>
207
    public int FieldCount => _dataReader.FieldCount;
×
208

209
    /// <summary>
210
    /// Gets the value of the field at the specified index.
211
    /// </summary>
212
    /// <param name="i">The zero-based index of the field.</param>
213
    /// <returns>The value of the field as an <see cref="object"/>.</returns>
214
    object IDataRecord.this[int i] => _dataReader[i];
×
215

216
    /// <summary>
217
    /// Gets the value of the field with the specified name, applying the field prefix if set.
218
    /// </summary>
219
    /// <param name="name">The name of the field.</param>
220
    /// <returns>The value of the field as an <see cref="object"/>.</returns>
221
    object IDataRecord.this[string name]
222
    {
223
        get
224
        {
225
            string prefixName = _fieldPrefix != null
×
226
                ? _fieldPrefix + name
×
227
                : name;
×
228

229
            return _dataReader[prefixName];
×
230
        }
231
    }
232

233
    /// <summary>
234
    /// Releases all resources used by the <see cref="DataReaderWrapper"/> and the underlying <see cref="IDataReader"/>.
235
    /// </summary>
236
    public void Dispose() => _dataReader.Dispose();
×
237

238
    /// <summary>
239
    /// Closes the underlying <see cref="IDataReader"/>.
240
    /// </summary>
241
    public void Close() => _dataReader.Dispose();
×
242

243
    /// <summary>
244
    /// Returns a <see cref="DataTable"/> that describes the column metadata of the <see cref="IDataReader"/>.
245
    /// </summary>
246
    /// <returns>A <see cref="DataTable"/> that describes the column metadata.</returns>
NEW
247
    public DataTable? GetSchemaTable() => _dataReader.GetSchemaTable();
×
248

249
    /// <summary>
250
    /// Advances the data reader to the next result, when reading the results of batch SQL statements.
251
    /// </summary>
252
    /// <returns><c>true</c> if there are more result sets; otherwise, <c>false</c>.</returns>
253
    public bool NextResult() => _dataReader.NextResult();
×
254

255
    /// <summary>
256
    /// Advances the <see cref="IDataReader"/> to the next record.
257
    /// </summary>
258
    /// <returns><c>true</c> if there are more rows; otherwise, <c>false</c>.</returns>
259
    public bool Read() => _dataReader.Read();
×
260

261
    /// <summary>
262
    /// Gets a value indicating the depth of nesting for the current row.
263
    /// </summary>
264
    public int Depth => _dataReader.Depth;
×
265

266
    /// <summary>
267
    /// Gets a value indicating whether the data reader is closed.
268
    /// </summary>
269
    public bool IsClosed => _dataReader.IsClosed;
×
270

271
    /// <summary>
272
    /// Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.
273
    /// </summary>
274
    public int RecordsAffected => _dataReader.RecordsAffected;
×
275
}
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