Table of Contents

Method OrdinalMapping

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

OrdinalMapping(IDataRecord)

Lazily enumerates the name and ordinal of every column in the current result set.

public static IEnumerable<ColumnOrdinal> OrdinalMapping(this IDataRecord record)

Parameters

record IDataRecord

The record to get the column names from.

Returns

IEnumerable<ColumnOrdinal>

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<ColumnOrdinal> OrdinalMapping(this IDataRecord record, IEnumerable<string> columnNames)

Parameters

record IDataRecord

The record to query the ordinals from.

columnNames IEnumerable<string>

The requested column names, looked up with GetOrdinal(string), which falls back to a case-insensitive match.

Returns

IEnumerable<ColumnOrdinal>

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

ArgumentNullException

record or columnNames is null. It is thrown by the call, not while the result is enumerated.

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<ColumnOrdinal> 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<ColumnOrdinal>

An enumerable of mappings.

Exceptions

ArgumentNullException

record or columnNames is null. It is thrown by the call, not while the result is enumerated.

IndexOutOfRangeException

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

See Also