Struct WriteResult<T>
- Namespace
- DynaSharp
- Assembly
- DynaSharp.dll
What a put, an update or a delete returns.
public readonly struct WriteResult<T>
Type Parameters
TThe type of the item.
- Inherited Members
Properties
ConditionMet
Gets a value indicating whether the condition of the write held, so that the write took effect. It is true on every result of SendAsync, which throws
ConditionalCheckFailedException instead, and on a write without a condition. false comes only from TrySendAsync, for a condition that did not hold:
nothing was written, Item is the item the condition saw if ReturnOldOnFailure() asked for it, and Version, ConsumedCapacity and
ItemCollectionMetrics are null.
public bool ConditionMet { get; }
Property Value
Remarks
After a response that was lost, the client sends the write again, and a conditional write that took effect the first time then fails against itself. On the wire that is the same as a write that an earlier delivery of the same change already made, so false does not say which: compare what Item holds with what the write sent. Equal means that the change is stored, by this call or an earlier one.
ConsumedCapacity
Gets the capacity the write consumed, if ReturnCapacity asked for it.
public ConsumedCapacity? ConsumedCapacity { get; }
Property Value
HasItem
Gets a value indicating whether the response holds an item. It is what to test, because an entity may be a struct.
[MemberNotNullWhen(true, "Item")]
public bool HasItem { get; }
Property Value
Item
Gets the item that ReturnOld or ReturnNew asked for, or the default value of T if there is none: nothing
was asked for, or ReturnOld found no item under the key. When ConditionMet is false, it is the item the condition saw, if
ReturnOldOnFailure() asked for it and an item had the key; ReturnOld and ReturnNew give nothing then.
public T? Item { get; }
Property Value
- T
ItemCollectionMetrics
Gets the size estimate of the item collection, if ReturnMetrics asked for it. DynamoDB sends it for a table with a local secondary
index, and it contains the partition key value, so it never reaches telemetry.
public ItemCollectionMetrics? ItemCollectionMetrics { get; }
Property Value
Version
Gets the version the write stored for a VersionAttribute entity, which is what the next write expects: a put stores the version of its
entity plus one, also with .IgnoreVersion(), and an update the one of .IfVersion(n) plus one. null if it stored
none it knows: a delete, an update with .IgnoreVersion(), which advances a version it does not know, a type without a version, or a write of TrySendAsync whose condition did not hold, which wrote nothing.
The entity of a put stays as it was.
public long? Version { get; }
Property Value
- long?
Remarks
Whether a write stores a version depends on the chain and, for TrySendAsync, on the answer, so the type cannot say it, and the value is the one place that does.
Code that knows its write stored one, a put of a VersionAttribute entity or an update with .IfVersion(n) sent with SendAsync, takes
result.Version!.Value, and code that does not asks with result.Version is { } next.