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
recordIDataRecordThe record to query the ordinals from.
columnNamesIEnumerable<string>The requested column names. Names that do not exist in the record are skipped rather than reported.
sortbooltrue 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
Use OrdinalMapping(IDataRecord, IEnumerable<string>) or GetOrdinalMapping(IDataRecord, IEnumerable<string>, bool) instead when a missing column should be an error.
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.