Table of Contents

Method MatchingOrdinals

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

MatchingOrdinals(IDataRecord, IEnumerable<string>, bool)

Finds the requested columns that exist in the record, matching names case-insensitively.

public static IEnumerable<(string Name, int Ordinal)> MatchingOrdinals(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

IEnumerable<(string Name, int Ordinal)>

An enumerable 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.