Skip to content

Commit bfda8c6

Browse files
author
Oren (electricessence)
committed
Added auto-transforming AsSourceBlockAsync
1 parent 7f432f5 commit bfda8c6

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

Documentation.xml

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

ExpressiveDbCommandBase.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,26 @@ public ISourceBlock<T> AsSourceBlockAsync<T>(params (string Field, string Column
457457
where T : new()
458458
=> AsSourceBlockAsync<T>(fieldMappingOverrides as IEnumerable<(string Field, string Column)>);
459459

460-
461-
/// <summary>
462-
/// Asynchronously returns all records via a transform function.
463-
/// </summary>
464-
/// <param name="transform">The desired column names.</param>
465-
/// <param name="behavior">The behavior to use with the data reader.</param>
466-
/// <returns>A task containing the list of results.</returns>
467-
public async Task<List<T>> ToListAsync<T>(Func<IDataRecord, T> transform, CommandBehavior behavior = CommandBehavior.Default)
460+
/// <summary>
461+
/// Returns a source block as the source of records.
462+
/// </summary>
463+
/// <typeparam name="T">The model type to map the values to (using reflection).</typeparam>
464+
/// <param name="options">The optional ExecutionDataflowBlockOptions to use with the source.</param>
465+
/// <param name="fieldMappingOverrides">An override map of field names to column names where the keys are the property names, and values are the column names.</param>
466+
/// <returns>A transform block that is receiving the results.</returns>
467+
public ISourceBlock<T> AsSourceBlockAsync<T>(
468+
ExecutionDataflowBlockOptions options,
469+
params (string Field, string Column)[] fieldMappingOverrides)
470+
where T : new()
471+
=> AsSourceBlockAsync<T>(fieldMappingOverrides as IEnumerable<(string Field, string Column)>, options);
472+
473+
/// <summary>
474+
/// Asynchronously returns all records via a transform function.
475+
/// </summary>
476+
/// <param name="transform">The desired column names.</param>
477+
/// <param name="behavior">The behavior to use with the data reader.</param>
478+
/// <returns>A task containing the list of results.</returns>
479+
public async Task<List<T>> ToListAsync<T>(Func<IDataRecord, T> transform, CommandBehavior behavior = CommandBehavior.Default)
468480
{
469481
var results = new List<T>();
470482
await IterateReaderAsync(record => results.Add(transform(record)), behavior).ConfigureAwait(false);

Open.Database.Extensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Description>Useful set of utilities and abstractions for simplifying modern data-access operations and ensuring DI compatibility.</Description>
1212
<RepositoryUrl>https://github.com/electricessence/Open.Database.Extensions</RepositoryUrl>
1313
<RepositoryType>git</RepositoryType>
14-
<Version>5.13.0</Version>
14+
<Version>5.13.1</Version>
1515
<AssemblyVersion>5.13.0.0</AssemblyVersion>
1616
<FileVersion>5.13.0.0</FileVersion>
1717
<PackageReleaseNotes>Cleanup and inspection fixes with added Dataflow options.

0 commit comments

Comments
 (0)