Table of Contents

Method GetOrdinalMapping

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

GetOrdinalMapping(IDataRecord, IEnumerable<string>, bool)

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

public static (string Name, int Ordinal)[] GetOrdinalMapping(this IDataRecord record, IEnumerable<string> columnNames, bool sort = false)

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

(string Name, int Ordinal)[]

An array of mappings. It is empty if columnNames is an empty collection.

Exceptions

IndexOutOfRangeException

One or more requested columns do not exist. The message lists all the invalid names.

See Also