Table of Contents

Struct PutStep

Namespace
DynaSharp
Assembly
DynaSharp.dll

A put in a transaction: what can follow it are its condition, the verbs of the next action, and sending. Attributes of an update do not exist here, so .Add after .Put does not compile. See TransactWriteExtensions for the rest.

public readonly ref struct PutStep : ITransactWriteStep<PutStep>, ITransactWriteChain<PutStep>, IConditional<PutStep>, IRetryable<PutStep>
Implements
Inherited Members
Extension Methods

Methods

If(ExpressionHandler)

Adds a condition in the grammar of DynamoDB, for what the conditions of handles do not cover. An interpolated Attr stands for an attribute name and any other interpolated value for a value. If it does not hold, the whole transaction is cancelled, and a second condition means both must hold.

public PutStep If(ExpressionHandler condition)

Parameters

condition ExpressionHandler

The condition.

Returns

PutStep

The step, which replaces this one.

If<TCondition>(TCondition)

Adds a condition. If it does not hold, the whole transaction is cancelled, and a second condition means both must hold.

public PutStep If<TCondition>(TCondition condition) where TCondition : ICondition

Parameters

condition TCondition

The condition.

Returns

PutStep

The step, which replaces this one.

Type Parameters

TCondition

The type of the condition.

Exceptions

ArgumentNullException

condition is null.

IgnoreVersion()

Writes the entity of this put without the check of its version, and still stores the next version, as a checked put does. Conditions of your own stay, and the other actions of the transaction are not touched. On a type without a VersionAttribute it changes nothing. See IgnoreVersion<T>(PutCommand<T>).

public PutStep IgnoreVersion()

Returns

PutStep

The step, which replaces this one.

Remarks

The version still advances. Every write of a versioned entity stores a new version, also one without the check: an update adds 1 to the stored version, SET #v = if_not_exists(#v, :zero) + :one, so an item without one, or a new item, gets version 1, and a put or a batch stores the version of its entity plus one, as a checked put does. A writer that holds a copy read before this write then fails with ConditionalCheckFailedException, or in a transaction with TransactionCanceledException, instead of overwriting it. What this write itself overwrites is not checked: it wins over whatever another writer stored since, so it suits a change that does not depend on what was read, such as an Add to a counter.

MaxAttempts(int)

Sets the number of attempts of this call including the first, in place of MaxAttempts. A retry after a lost response repeats a write that may have been applied, so 1 makes an ADD count at most once, and a lost response then reports a failure after the write was applied.

public PutStep MaxAttempts(int attempts)

Parameters

attempts int

The number of attempts.

Returns

PutStep

The command, which replaces this one.

Exceptions

ArgumentOutOfRangeException

attempts is below 1.

ToRequestJson()

Renders the body this transaction would send, as DynamoDB JSON, without sending it. It ends the command, and is meant for tests and debugging. The text contains the items and a generated token that nothing ever sends.

public string ToRequestJson()

Returns

string

The request body.

Exceptions

InvalidOperationException

The command was already sent, extended or rendered, or it has no action, which DynamoDB would reject.

Operators

implicit operator TransactWriteCommand(PutStep)

Hands the transaction on as a TransactWriteCommand, which is what a variable holds across a loop: tx = tx.Put(table, item).IfNotExists();. This uses the step up like any call on it, so the command is the one handle left, and a clause of the action can no longer follow.

public static implicit operator TransactWriteCommand(PutStep step)

Parameters

step PutStep

The step, which this replaces.

Returns

TransactWriteCommand

Exceptions

InvalidOperationException

The step was already sent, extended or rendered.