Table of Contents

Struct DictionaryRow

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

One row of a result set read without a model: the values of the row and, by name, the columns they came from.

public readonly struct DictionaryRow : IReadOnlyDictionary<string, object?>, IReadOnlyCollection<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>, IEnumerable
Implements
Inherited Members

Remarks

Made by AsDictionaryRows(). Each column is one slot of the row, a database NULL reads as null, and every row of a result set shares the same column names.

The dictionary side (Count, Keys, Values, the enumeration, ContainsKey(string), TryGetValue(string, out object?), the string indexer and ToDictionary()) is over the distinct column names, and the first column with a name wins. A name is found exactly, else ignoring case. The ordinal indexer and FieldCount reach every column, duplicates included. A missing name throws KeyNotFoundException; a cell that holds a database NULL is present with the value null.

ToDictionary() and Values build a new collection on each call. To read one value by name, use the indexer or TryGetValue(string, out object?).

A result set with no rows gives no row, so no column names: an empty result exposes none. default(DictionaryRow) is an empty row. It is not a model: Map<DictionaryRow>() throws InvalidOperationException, and the message names AsDictionaryRows().

Properties

Count

Gets the number of distinct column names.

FieldCount

Gets the number of columns of the row, duplicate names included.

this[int]

Gets the value of a column by its position.

this[string]

Gets the value of the first column with a name.

Keys

Gets the distinct column names, in the order of their first column.

Values

Gets the values of the first column of each distinct name, in the same order as Keys.

Methods

ContainsKey(string)

Determines whether a column has the name: among the distinct names, exactly, else ignoring case.

GetEnumerator()

Gets an enumerator over the distinct names and their values.

ToDictionary()

Copies the row to a new dictionary of the distinct names, which the caller owns.

TryGetValue(string, out object?)

Gets the value of the first column with a name.