Table of Contents

Method OrdinalMapping

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

OrdinalMapping(IDataRecord)

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

public static IEnumerable<(string Name, int Ordinal)> OrdinalMapping(this IDataRecord record)

Parameters

record IDataRecord

The record to get the column names from.

Returns

IEnumerable<(string Name, int Ordinal)>

An enumerable of the mappings in ordinal order.

Exceptions

ArgumentNullException

record is null.

OrdinalMapping(IDataRecord, IEnumerable<string>)

Lazily looks up the ordinal of each requested column.

public static IEnumerable<(string Name, int Ordinal)> OrdinalMapping(this IDataRecord record, IEnumerable<string> columnNames)

Parameters

record IDataRecord

The record to query the ordinals from.

columnNames IEnumerable<string>

The requested column names. The lookup uses GetOrdinal(string), which tries a case-sensitive match before a case-insensitive one.

Returns

IEnumerable<(string Name, int Ordinal)>

An enumerable of mappings, in the order requested. Each name is the column's actual name in the record, which can differ in casing from the requested name.

Exceptions

IndexOutOfRangeException

A requested column does not exist. It is thrown while the result is enumerated.

See Also

OrdinalMapping(IDataRecord, IEnumerable<string>, bool)

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

public static IEnumerable<(string Name, int Ordinal)> OrdinalMapping(this IDataRecord record, IEnumerable<string> columnNames, bool sort)

Parameters

record IDataRecord

The record to query the ordinals from.

columnNames IEnumerable<string>

The requested column names.

sort bool

true to order the results by ordinal ascending; false to keep the requested order.

Returns

IEnumerable<(string Name, int Ordinal)>

An enumerable of mappings.

Exceptions

IndexOutOfRangeException

A requested column does not exist. It is thrown while the result is enumerated.

See Also