Table of Contents

Struct SelectResult<TValue>

Namespace
DynaSharp
Assembly
DynaSharp.dll

What a read of one attribute gives when there may be no item: GetItem without one, or a query in which nothing matches. It has the shape of GetResult<T> with one difference: there, Found says that Item is not null, which an attribute cannot promise, because a nullable one can be missing from an item that exists.

public readonly struct SelectResult<TValue>

Type Parameters

TValue

The type of the attribute, nullable for a handle of a nullable property.

Inherited Members

Remarks

Found is about the item and Value about the attribute, so a nullable attribute tells all three apart: no item, an item without the attribute, and a value. A handle that cannot be null has only two of them, because an item without the attribute throws DynamoDbMappingException, unless it has an answer for that: a set is empty, and a version with Allow is 0. That answer is about an item that exists. No item is Found false, whatever the handle, and Value throws.

Properties

ConsumedCapacity

Gets the capacity the read consumed, if ReturnCapacity asked for it. For a query it is that of the last page: the pages before it reach the metric and no other place.

public ConsumedCapacity? ConsumedCapacity { get; }

Property Value

ConsumedCapacity

Found

Gets a value indicating whether an item exists. It says nothing about the attribute, which can be missing and null for a nullable handle.

public bool Found { get; }

Property Value

bool

Value

Gets the value of the attribute. A read that found no item has none, which is not the same as an item without the attribute, so look at Found first: result.Found ? result.Value : fallback, which GetValueOrDefault(TValue) says in one call. DYNA227 reports a read of this in a method that never looks at Found.

public TValue Value { get; }

Property Value

TValue

Exceptions

InvalidOperationException

There is no item, so there is no value. A default would read like one, so test Found first.

Methods

GetValueOrDefault()

Gets the value of the attribute, or the default value of TValue when the read found no item, as GetValueOrDefault() does: 0 for an int, null for a string?. It does not throw, so it is for code that treats no item as that value. A nullable handle gives null also for an item without the attribute, so there it cannot tell the two apart; Found can.

public TValue? GetValueOrDefault()

Returns

TValue

The value, or the default value of the type.

GetValueOrDefault(TValue)

Gets the value of the attribute, or defaultValue when the read found no item: (await totals).GetValueOrDefault(-1m). An item whose attribute is null gives that null, not the fallback.

public TValue GetValueOrDefault(TValue defaultValue)

Parameters

defaultValue TValue

What no item gives.

Returns

TValue

The value, or defaultValue.