Table of Contents

Class DynaObject

Namespace
Rinku.Mapping
Assembly
Rinku.dll

A row read without a type to map to, its columns reachable by name or index. Ask for a DynaObject when the shape is not known ahead of time, it reads like a dictionary of the result's columns and serializes to JSON as one. Values keep their column types, read them with Get<T>(string).

[JsonConverter(typeof(DynaObjectConverter))]
public abstract class DynaObject : IReadOnlyDictionary<string, object?>, IReadOnlyCollection<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>, IReadOnlyDictionary<string, int>, IReadOnlyCollection<KeyValuePair<string, int>>, IEnumerable<KeyValuePair<string, int>>, IEnumerable
Inheritance
DynaObject
Implements
Inherited Members
Extension Methods

Fields

Mapper

Gets the column names and their indexes.

public readonly Mapper Mapper

Field Value

Mapper

Properties

Count

Gets the number of elements in the collection.

public int Count { get; }

Property Value

int

The number of elements in the collection.

this[int]

public object? this[int ind] { get; set; }

Parameters

ind int

Property Value

object

this[ReadOnlySpan<char>]

public object? this[ReadOnlySpan<char> key] { get; set; }

Parameters

key ReadOnlySpan<char>

Property Value

object

this[string]

Gets the element that has the specified key in the read-only dictionary.

public object? this[string key] { get; set; }

Parameters

key string

The key to locate.

Property Value

object

The element that has the specified key in the read-only dictionary.

Exceptions

ArgumentNullException

key is null.

KeyNotFoundException

The property is retrieved and key is not found.

Keys

Gets the unique keys held by this mapper as a ReadOnlySpan<T>.

public ReadOnlySpan<string> Keys { get; }

Property Value

ReadOnlySpan<string>

Values

Gets an enumerable collection that contains the values in the read-only dictionary.

public IEnumerable<object?> Values { get; }

Property Value

IEnumerable<object>

An enumerable collection that contains the values in the read-only dictionary.

Methods

ContainsKey(ReadOnlySpan<char>)

public bool ContainsKey(ReadOnlySpan<char> key)

Parameters

key ReadOnlySpan<char>

Returns

bool

ContainsKey(string)

Determines whether the read-only dictionary contains an element that has the specified key.

public bool ContainsKey(string key)

Parameters

key string

The key to locate.

Returns

bool

true if the read-only dictionary contains an element that has the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<KeyValuePair<string, object?>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, object>>

An enumerator that can be used to iterate through the collection.

Get<T>(int)

Gets the value at the given column index.

public T Get<T>(int index)

Parameters

index int

Returns

T

Type Parameters

T

Get<T>(ReadOnlySpan<char>)

Gets the value from the named column.

public T Get<T>(ReadOnlySpan<char> key)

Parameters

key ReadOnlySpan<char>

Returns

T

Type Parameters

T

Get<T>(string)

Gets the value from the named column.

public T Get<T>(string key)

Parameters

key string

Returns

T

Type Parameters

T

Set<T>(int, T)

Tries to replace the value at the given column index.

public abstract bool Set<T>(int index, T value)

Parameters

index int
value T

Returns

bool

Type Parameters

T

Set<T>(ReadOnlySpan<char>, T)

Tries to replace the value in the named column.

public bool Set<T>(ReadOnlySpan<char> key, T value)

Parameters

key ReadOnlySpan<char>
value T

Returns

bool

Type Parameters

T

Set<T>(string, T)

Tries to replace the value in the named column.

public bool Set<T>(string key, T value)

Parameters

key string
value T

Returns

bool

Type Parameters

T

TryGetValue(ReadOnlySpan<char>, out object?)

public bool TryGetValue(ReadOnlySpan<char> key, out object? value)

Parameters

key ReadOnlySpan<char>
value object

Returns

bool

TryGetValue(string, out int)

Gets the value that is associated with the specified key.

public bool TryGetValue(string key, out int value)

Parameters

key string

The key to locate.

value int

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

true if the object that implements the IReadOnlyDictionary<TKey, TValue> interface contains an element that has the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

TryGetValue(string, out object?)

Gets the value that is associated with the specified key.

public bool TryGetValue(string key, out object? value)

Parameters

key string

The key to locate.

value object

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

true if the object that implements the IReadOnlyDictionary<TKey, TValue> interface contains an element that has the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

TryGetValue<T>(ReadOnlySpan<char>, out T)

public bool TryGetValue<T>(ReadOnlySpan<char> key, out T value)

Parameters

key ReadOnlySpan<char>
value T

Returns

bool

Type Parameters

T

TryGetValue<T>(string, out T)

public bool TryGetValue<T>(string key, out T value)

Parameters

key string
value T

Returns

bool

Type Parameters

T

TryGet<T>(int, out T)

Tries to read the value at the given column index.

public abstract bool TryGet<T>(int index, out T val)

Parameters

index int
val T

Returns

bool

Type Parameters

T

TrySet<T, TField>(T, ref TField?)

Stores value into field when its type matches, used while filling a typed slot.

protected static bool TrySet<T, TField>(T value, ref TField? field)

Parameters

value T
field TField

Returns

bool

Type Parameters

T
TField

WriteJsonProperties(Utf8JsonWriter, JsonSerializerOptions)

Writes the columns as JSON properties, used by the JSON converter.

public abstract void WriteJsonProperties(Utf8JsonWriter writer, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter
options JsonSerializerOptions