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
recordIDataRecordThe record to query the ordinals from.
columnNamesIEnumerable<string>The requested column names.
sortbooltrue 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
columnNamesis an empty collection.
Exceptions
- IndexOutOfRangeException
One or more requested columns do not exist. The message lists all the invalid names.
- See Also