Skip to content

Commit c8886cc

Browse files
author
Oren (electricessence)
committed
Added DBNull conversions where it makes sense and appended documentation.
Exposed DBNull extensions.
1 parent e11470c commit c8886cc

File tree

6 files changed

+337
-80
lines changed

6 files changed

+337
-80
lines changed

Documentation.xml

Lines changed: 120 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ExpressiveCommandBase.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,15 @@ public T[] ToArray<T>(Func<IDataRecord, T> transform)
498498

499499
/// <summary>
500500
/// Iterates all records within the first result set using an IDataReader and returns the results.
501+
/// DBNull values are left unchanged (retained).
501502
/// </summary>
502503
/// <returns>The QueryResult that contains all the results and the column mappings.</returns>
503504
public QueryResult<Queue<object[]>> Retrieve()
504505
=> Execute(command => command.Retrieve());
505506

506507
/// <summary>
507508
/// Iterates all records within the current result set using an IDataReader and returns the desired results.
509+
/// DBNull values are left unchanged (retained).
508510
/// </summary>
509511
/// <param name="ordinals">The ordinals to request from the reader for each record.</param>
510512
/// <returns>The QueryResult that contains all the results and the column mappings.</returns>
@@ -513,6 +515,7 @@ public QueryResult<Queue<object[]>> Retrieve(IEnumerable<int> ordinals)
513515

514516
/// <summary>
515517
/// Iterates all records within the current result set using an IDataReader and returns the desired results.
518+
/// DBNull values are left unchanged (retained).
516519
/// </summary>
517520
/// <param name="n">The first ordinal to include in the request to the reader for each record.</param>
518521
/// <param name="others">The remaining ordinals to request from the reader for each record.</param>
@@ -522,6 +525,7 @@ public QueryResult<Queue<object[]>> Retrieve(int n, params int[] others)
522525

523526
/// <summary>
524527
/// Iterates all records within the first result set using an IDataReader and returns the desired results as a list of Dictionaries containing only the specified column values.
528+
/// DBNull values are left unchanged (retained).
525529
/// </summary>
526530
/// <param name="columnNames">The column names to select.</param>
527531
/// <returns>The QueryResult that contains all the results and the column mappings.</returns>
@@ -530,6 +534,7 @@ public QueryResult<Queue<object[]>> Retrieve(IEnumerable<string> columnNames)
530534

531535
/// <summary>
532536
/// Iterates all records within the current result set using an IDataReader and returns the desired results.
537+
/// DBNull values are left unchanged (retained).
533538
/// </summary>
534539
/// <param name="c">The first column name to include in the request to the reader for each record.</param>
535540
/// <param name="others">The remaining column names to request from the reader for each record.</param>
@@ -560,15 +565,17 @@ public IEnumerable<T> Results<T>(IEnumerable<(string Field, string Column)> fiel
560565
=> Execute(command => command.Results<T>(fieldMappingOverrides));
561566

562567
/// <summary>
563-
/// Reads the first column from every record and returns the results as a list.
568+
/// Reads the first column from every record and returns the results as a list..
569+
/// DBNull values are converted to null.
564570
/// </summary>
565571
/// <returns>The list of transformed records.</returns>
566-
public List<object> FirstOrdinalResults()
567-
=> ToList(r => r.GetValue(0));
572+
public IEnumerable<object> FirstOrdinalResults()
573+
=> Execute(command => command.FirstOrdinalResults());
568574

569575

570576
/// <summary>
571-
/// Reads the first column from every record.
577+
/// Reads the first column from every record..
578+
/// DBNull values are converted to null.
572579
/// </summary>
573580
/// <returns>The enumerable of casted values.</returns>
574581
public IEnumerable<T0> FirstOrdinalResults<T0>()

ExpressiveDbCommandBase.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public async Task<T> ExecuteScalarAsync<T>(Func<object, Task<T>> transform)
175175
/// <param name="token">An optional cancellation token.</param>
176176
/// <returns></returns>
177177
public Task IterateReaderAsync(Action<IDataRecord> handler, CancellationToken? token = null)
178-
=> ExecuteAsync(command => command.IterateReaderAsync(handler, token));
178+
=> ExecuteAsync(command => command.ForEachAsync(handler, token));
179179

180180
/// <summary>
181181
/// Iterates asynchronously until the handler returns false. Then cancels.
@@ -218,15 +218,16 @@ public Task<List<T>> TakeAsync<T>(Func<IDataRecord, T> transform, int count)
218218

219219

220220
/// <summary>
221-
/// Reads the first column from every record and returns the results as a list.
221+
/// Reads the first column from every record and returns the results as a list..
222+
/// DBNull values are converted to null.
222223
/// </summary>
223224
/// <returns>The list of transformed records.</returns>
224-
public Task<List<object>> FirstOrdinalResultsAsync()
225-
=> ToListAsync(r => r.GetValue(0));
226-
225+
public Task<IEnumerable<object>> FirstOrdinalResultsAsync()
226+
=> ExecuteAsync(command => command.FirstOrdinalResultsAsync());
227227

228228
/// <summary>
229-
/// Reads the first column from every record.
229+
/// Reads the first column from every record..
230+
/// DBNull values are converted to null.
230231
/// </summary>
231232
/// <returns>The enumerable of casted values.</returns>
232233
public Task<IEnumerable<T0>> FirstOrdinalResultsAsync<T0>()

0 commit comments

Comments
 (0)