Method ResultsAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
ResultsAsync<T>(DbDataReader, IEnumerable<KeyValuePair<string, string?>>?, CancellationToken)
Asynchronously iterates each record and attempts to map the fields to type T.
public static IAsyncEnumerable<T> ResultsAsync<T>(this DbDataReader reader, IEnumerable<KeyValuePair<string, string?>>? fieldMappingOverrides = null, CancellationToken cancellationToken = default) where T : new()
Parameters
readerDbDataReaderThe IDataReader to read results from.
fieldMappingOverridesIEnumerable<KeyValuePair<string, string>>An optional override map of field names to column names where the keys are the property names, and values are the column names.
cancellationTokenCancellationTokenAn optional cancellation token.
Returns
- IAsyncEnumerable<T>
The enumerable to pull the transformed results from.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbDataReader, IEnumerable<(string Field, string? Column)>?, CancellationToken)
Asynchronously iterates each record and attempts to map the fields to type T.
public static IAsyncEnumerable<T> ResultsAsync<T>(this DbDataReader reader, IEnumerable<(string Field, string? Column)>? fieldMappingOverrides = null, CancellationToken cancellationToken = default) where T : new()
Parameters
readerDbDataReaderThe IDataReader to read results from.
fieldMappingOverridesIEnumerable<(string Field, string Column)>An optional override map of field names to column names where the keys are the property names, and values are the column names.
cancellationTokenCancellationTokenAn optional cancellation token.
Returns
- IAsyncEnumerable<T>
The enumerable to pull the transformed results from.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbDataReader, CancellationToken, params IEnumerable<KeyValuePair<string, string?>>?)
Asynchronously iterates each record and attempts to map the fields to type T.
public static IAsyncEnumerable<T> ResultsAsync<T>(this DbDataReader reader, CancellationToken cancellationToken, params IEnumerable<KeyValuePair<string, string?>>? fieldMappingOverrides) where T : new()
Parameters
readerDbDataReaderThe IDataReader to read results from.
cancellationTokenCancellationTokenAn optional cancellation token.
fieldMappingOverridesIEnumerable<KeyValuePair<string, string>>An optional override map of field names to column names where the keys are the property names, and values are the column names.
Returns
- IAsyncEnumerable<T>
The enumerable to pull the transformed results from.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbDataReader, CancellationToken, params IEnumerable<(string Field, string? Column)>?)
Asynchronously iterates each record and attempts to map the fields to type T.
public static IAsyncEnumerable<T> ResultsAsync<T>(this DbDataReader reader, CancellationToken cancellationToken, params IEnumerable<(string Field, string? Column)>? fieldMappingOverrides) where T : new()
Parameters
readerDbDataReaderThe IDataReader to read results from.
cancellationTokenCancellationTokenAn optional cancellation token.
fieldMappingOverridesIEnumerable<(string Field, string Column)>An optional override map of field names to column names where the keys are the property names, and values are the column names.
Returns
- IAsyncEnumerable<T>
The enumerable to pull the transformed results from.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbCommand, IEnumerable<KeyValuePair<string, string?>>?, bool, CancellationToken)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
public static ValueTask<IEnumerable<T>> ResultsAsync<T>(this DbCommand command, IEnumerable<KeyValuePair<string, string?>>? fieldMappingOverrides = null, bool useReadAsync = true, CancellationToken cancellationToken = default) where T : new()
Parameters
commandDbCommandThe command to generate a reader from.
fieldMappingOverridesIEnumerable<KeyValuePair<string, string>>An override map of field names to column names where the keys are the property names, and values are the column names.
useReadAsyncboolIf true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- ValueTask<IEnumerable<T>>
A task containing the list of results.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbCommand, IEnumerable<KeyValuePair<string, string?>>?, CancellationToken)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
public static ValueTask<IEnumerable<T>> ResultsAsync<T>(this DbCommand command, IEnumerable<KeyValuePair<string, string?>>? fieldMappingOverrides, CancellationToken cancellationToken = default) where T : new()
Parameters
commandDbCommandThe command to generate a reader from.
fieldMappingOverridesIEnumerable<KeyValuePair<string, string>>An override map of field names to column names where the keys are the property names, and values are the column names.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- ValueTask<IEnumerable<T>>
A task containing the list of results.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbCommand, CancellationToken, params IEnumerable<KeyValuePair<string, string?>>?)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
public static ValueTask<IEnumerable<T>> ResultsAsync<T>(this DbCommand command, CancellationToken cancellationToken, params IEnumerable<KeyValuePair<string, string?>>? fieldMappingOverrides) where T : new()
Parameters
commandDbCommandThe command to generate a reader from.
cancellationTokenCancellationTokenOptional cancellation token.
fieldMappingOverridesIEnumerable<KeyValuePair<string, string>>An override map of field names to column names where the keys are the property names, and values are the column names.
Returns
- ValueTask<IEnumerable<T>>
A task containing the list of results.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbCommand, CancellationToken)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
public static ValueTask<IEnumerable<T>> ResultsAsync<T>(this DbCommand command, CancellationToken cancellationToken) where T : new()
Parameters
commandDbCommandThe command to generate a reader from.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- ValueTask<IEnumerable<T>>
A task containing the list of results.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbCommand, IEnumerable<(string Field, string? Column)>?, bool, CancellationToken)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
public static ValueTask<IEnumerable<T>> ResultsAsync<T>(this DbCommand command, IEnumerable<(string Field, string? Column)>? fieldMappingOverrides = null, bool useReadAsync = true, CancellationToken cancellationToken = default) where T : new()
Parameters
commandDbCommandThe command to generate a reader from.
fieldMappingOverridesIEnumerable<(string Field, string Column)>An override map of field names to column names where the keys are the property names, and values are the column names.
useReadAsyncboolIf true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- ValueTask<IEnumerable<T>>
A task containing the list of results.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbCommand, IEnumerable<(string Field, string? Column)>?, CancellationToken)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
public static ValueTask<IEnumerable<T>> ResultsAsync<T>(this DbCommand command, IEnumerable<(string Field, string? Column)>? fieldMappingOverrides, CancellationToken cancellationToken = default) where T : new()
Parameters
commandDbCommandThe command to generate a reader from.
fieldMappingOverridesIEnumerable<(string Field, string Column)>An override map of field names to column names where the keys are the property names, and values are the column names.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- ValueTask<IEnumerable<T>>
A task containing the list of results.
Type Parameters
TThe model type to map the values to (using reflection).
ResultsAsync<T>(DbCommand, CancellationToken, params (string Field, string? Column)[])
Asynchronously returns all records and iteratively attempts to map the fields to type T.
public static ValueTask<IEnumerable<T>> ResultsAsync<T>(this DbCommand command, CancellationToken cancellationToken, params (string Field, string? Column)[] fieldMappingOverrides) where T : new()
Parameters
commandDbCommandThe command to generate a reader from.
cancellationTokenCancellationTokenOptional cancellation token.
fieldMappingOverrides(string Field, string Column)[]An override map of field names to column names where the keys are the property names, and values are the column names.
Returns
- ValueTask<IEnumerable<T>>
A task containing the list of results.
Type Parameters
TThe model type to map the values to (using reflection).