Google.Cloud.Spanner.Data - Class SpannerTransactionCreationOptions (5.0.0-beta04)

public sealed class SpannerTransactionCreationOptions

Reference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerTransactionCreationOptions.

Options that may be provided when creating a SpannerTransaction. Instances of this class are immutable.

Inheritance

object > SpannerTransactionCreationOptions

Namespace

Google.Cloud.Spanner.Data

Assembly

Google.Cloud.Spanner.Data.dll

Properties

ExcludeFromChangeStreams

public bool ExcludeFromChangeStreams { get; }

Whether changes executed within this transaction are recorded in change streams or not. This will always be false for read-only transactions.

Property Value
Type Description
bool
Remarks

A change stream may allow or not transaction exclusion. Setting this value to true will only have effect on change streams that allow transaction exclusion. That is, if this value is set to true changes executed withing this transaction will be excluded from change streams that allow transaction exclusion but will be tracked by change streams that do not explicitly allow transaction exclusion.

IsDetached

public bool IsDetached { get; }

Whether these options should result in a detached transaction or in one that's tracked by a session pool. This will always be true when TransactionId is set. Otherwise it will be false unless explicitly set via WithIsDetached(bool).

Property Value
Type Description
bool
Remarks

Resources of transactions that are tracked by a session pool will be returned to the pool once the transaction is committed or rolled back, for later re-use. Alternatively, a transaction that will be shared across processes, for instance for partitioned reads, should be detached so that resources are not returned to a local pool and attempted to be re-used there.

IsPartitionedDml

public bool IsPartitionedDml { get; }

Whether the resulting transaction is suitable for executing partioned DML queries. When this is true, TransactionMode will always be ReadWrite.

Property Value
Type Description
bool

IsSingleUse

public bool IsSingleUse { get; }

Whether these options should result in a single-use transaction or not. Only timestamp bound transactions may be single-use. A read-only transaction of MinReadTimestamp or MaxStaleness is always single-use. All other transactions are not single-use by default.

Property Value
Type Description
bool

PartitionedDml

public static SpannerTransactionCreationOptions PartitionedDml { get; }

Options that will result in a read-write transaction suitable for executing partioned DML.

Property Value
Type Description
SpannerTransactionCreationOptions

ReadOnly

public static SpannerTransactionCreationOptions ReadOnly { get; }

Options that will result in a read-only transaction bound by Strong.

Property Value
Type Description
SpannerTransactionCreationOptions

ReadWrite

public static SpannerTransactionCreationOptions ReadWrite { get; }

Options that will result in a read-write transaction.

Property Value
Type Description
SpannerTransactionCreationOptions

TimestampBound

public TimestampBound TimestampBound { get; }

Timestamp bound settings for the transaction. May be null. When set, the transaction will be read-only. At most, one of TimestampBound and TransactionId may be set. If none of TimestampBound and TransactionId are set, the transaction will be a read-write transaction.

Property Value
Type Description
TimestampBound

TransactionId

public TransactionId TransactionId { get; }

The transaction ID of an active read-only transaction to use for the transaction. May be null. At most, one of TimestampBound and TransactionId may be set. If none of TimestampBound and TransactionId are set, the transaction will be a read-write transaction.

Property Value
Type Description
TransactionId

Methods

ForTimestampBoundReadOnly(TimestampBound)

public static SpannerTransactionCreationOptions ForTimestampBoundReadOnly(TimestampBound timestampBound)

Creates transaction options with the given timestampBound options.

Parameter
Name Description
timestampBound TimestampBound

The timestamp bound options to be used for the transaction. May be null, this will return ReadOnly.

Returns
Type Description
SpannerTransactionCreationOptions

FromReadOnlyTransactionId(TransactionId)

public static SpannerTransactionCreationOptions FromReadOnlyTransactionId(TransactionId transactionId)

Creates transaction options with the given transactionId.

Parameter
Name Description
transactionId TransactionId

The transaction ID to use for the transaction. Must not be null.

Returns
Type Description
SpannerTransactionCreationOptions

WithExcludeFromChangeStreams(bool)

public SpannerTransactionCreationOptions WithExcludeFromChangeStreams(bool excludeFromChangeStreams)

Returns a new instance identical to this one except for the value of ExcludeFromChangeStreams. ExcludeFromChangeStreams can only be true for read-write transactions.

Parameter
Name Description
excludeFromChangeStreams bool
Returns
Type Description
SpannerTransactionCreationOptions

WithIsDetached(bool)

public SpannerTransactionCreationOptions WithIsDetached(bool isDetached)

Returns a new instance identical to this one except for the value of IsDetached. If TransactionId is set, IsDetached cannot be false.

Parameter
Name Description
isDetached bool
Returns
Type Description
SpannerTransactionCreationOptions

WithIsSingleUse(bool)

public SpannerTransactionCreationOptions WithIsSingleUse(bool isSingleUse)

Returns a new instance identical to this one except for the value of IsSingleUse. IsSingleUse can only be true for timestamp bound transactions. If timestamp bounds are of MinReadTimestamp or MaxStaleness, IsSingleUse cannot be false.

Parameter
Name Description
isSingleUse bool
Returns
Type Description
SpannerTransactionCreationOptions