Table of Contents

Class DataRecordExtensions

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

Extension methods for reading column names, data type names, ordinals, and values from an IDataRecord, such as a data reader positioned on a row.

public static class DataRecordExtensions
Inheritance
DataRecordExtensions
Inherited Members

Remarks

These methods read the record's current row and result-set metadata; they never advance the reader. Methods that return a lazy IEnumerable<T> read from the record while they are enumerated, so enumerate them before the reader advances or is disposed. Methods that return an array, ImmutableArray<T>, or dictionary read everything before they return. Null database values are represented as DBNull, except where noted.

Methods

ColumnNames(IDataRecord)

Lazily enumerates the column names of the current result set in ordinal order.

DataTypeNames(IDataRecord)

Lazily enumerates the provider's data type name of every column of the current result set, in ordinal order.

EnumerateValues(IDataRecord)

Lazily enumerates the value of every column of the current row in ordinal order.

EnumerateValuesFromOrdinals(IDataRecord, IEnumerable<int>)

Lazily enumerates the values of the columns at the specified ordinals.

EnumerateValuesFromOrdinals(IDataRecord, IReadOnlyList<int>)

Lazily enumerates the values of the columns at the specified ordinals.

EnumerateValuesFromOrdinals(IDataRecord, int, params IEnumerable<int>)

Lazily enumerates the values of the columns at the specified ordinals.

GetDataTypeNames(IDataRecord)

Gets the provider's data type name of every column of the current result set, in ordinal order.

GetMatchingOrdinals(IDataRecord, IEnumerable<string>, bool)

Finds the requested columns that exist in the record, matching names case-insensitively, and returns the mappings as an array.

GetNames(IDataRecord)

Gets all the column names of the current result set in ordinal order.

GetNames(IDataRecord, IEnumerable<int>)

Gets the column names at the specified ordinals.

GetOrdinalMapping(IDataRecord, IEnumerable<string>, bool)

Looks up the ordinal of each requested column and returns the mappings as an array.

GetValues(IDataRecord)

Reads the values of the current row into a new array sized to the record's FieldCount.

GetValues(IDataRecord, ArrayPool<object>)

Reads the values of the current row into an array rented from arrayPool, sized for the record's FieldCount.

GetValues(IDataRecord, int)

Reads the values of the current row into a new array of the specified length.

GetValues(IDataRecord, int, ArrayPool<object>)

Reads the values of the current row into an array rented from arrayPool.

GetValuesFromOrdinals(IDataRecord, IReadOnlyList<int>)

Reads the values of the columns at the specified ordinals into a new array.

GetValuesFromOrdinals(IDataRecord, ReadOnlySpan<int>, Span<object>)

Reads the values of the columns at the specified ordinals into the provided span.

GetValuesFromOrdinals<TList>(IDataRecord, IReadOnlyList<int>, TList)

Reads the values of the columns at the specified ordinals into the provided list.

MatchingOrdinals(IDataRecord, IEnumerable<string>, bool)

Finds the requested columns that exist in the record, matching names case-insensitively.

OrdinalMapping(IDataRecord)

Lazily enumerates the (name, ordinal) pairs of every column in the current result set.

OrdinalMapping(IDataRecord, IEnumerable<string>)

Lazily looks up the ordinal of each requested column.

OrdinalMapping(IDataRecord, IEnumerable<string>, bool)

Lazily looks up the ordinal of each requested column, optionally ordered by ordinal.

ToDictionary(IDataRecord, IEnumerable<KeyValuePair<int, string>>)

Reads the specified columns of the current row into a dictionary keyed by the supplied names.

ToDictionary(IDataRecord, IEnumerable<string>)

Reads the named columns of the current row into a dictionary keyed by column name.

ToDictionary(IDataRecord, IEnumerable<(string Name, int Ordinal)>)

Reads the specified columns of the current row into a dictionary keyed by column name.

ToDictionary(IDataRecord, IReadOnlyList<string>)

Reads the named columns of the current row into a dictionary keyed by column name.

ToDictionary(IDataRecord, IReadOnlyList<(string Name, int Ordinal)>)

Reads the specified columns of the current row into a dictionary keyed by column name.

ToDictionary(IDataRecord, ReadOnlySpan<string>)

Reads the named columns of the current row into a dictionary keyed by column name.

ToDictionary(IDataRecord, ReadOnlySpan<(string Name, int Ordinal)>)

Reads the specified columns of the current row into a dictionary keyed by column name.