Table of Contents

Method GetMatchingOrdinals

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

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.

public static (string Name, int Ordinal)[] GetMatchingOrdinals(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. Names that do not exist in the record are skipped rather than reported.

sort bool

true to return the mappings in the record's column order; false to return them in the requested order.

Returns

(string Name, int Ordinal)[]

An array of (name, ordinal) mappings, where each name is the column's actual name in the record.

Remarks

Exceptions

ArgumentException

A requested name is null, empty, or white space. It can be thrown when the result is enumerated rather than when this method is called.