Class SpannerTransactionCreationOptions
Options that may be provided when creating a SpannerTransaction. Instances of this class are immutable.
Namespace: Google.Cloud.Spanner.Data
Assembly: Google.Cloud.Spanner.Data.dll
Syntax
public sealed class SpannerTransactionCreationOptions
Properties
ExcludeFromChangeStreams
Whether changes executed within this transaction are recorded in change streams or not. This will always be false for read-only transactions.
Declaration
public bool ExcludeFromChangeStreams { get; }
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
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).
Declaration
public bool IsDetached { get; }
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
Whether the resulting transaction is suitable for executing partioned DML queries. When this is true, TransactionMode will always be ReadWrite.
Declaration
public bool IsPartitionedDml { get; }
Property Value
Type | Description |
---|---|
bool |
IsSingleUse
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.
Declaration
public bool IsSingleUse { get; }
Property Value
Type | Description |
---|---|
bool |
PartitionedDml
Options that will result in a read-write transaction suitable for executing partioned DML.
Declaration
public static SpannerTransactionCreationOptions PartitionedDml { get; }
Property Value
Type | Description |
---|---|
SpannerTransactionCreationOptions |
ReadOnly
Options that will result in a read-only transaction bound by Strong.
Declaration
public static SpannerTransactionCreationOptions ReadOnly { get; }
Property Value
Type | Description |
---|---|
SpannerTransactionCreationOptions |
ReadWrite
Options that will result in a read-write transaction.
Declaration
public static SpannerTransactionCreationOptions ReadWrite { get; }
Property Value
Type | Description |
---|---|
SpannerTransactionCreationOptions |
TimestampBound
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.
Declaration
public TimestampBound TimestampBound { get; }
Property Value
Type | Description |
---|---|
TimestampBound |
TransactionId
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.
Declaration
public TransactionId TransactionId { get; }
Property Value
Type | Description |
---|---|
TransactionId |
Methods
ForTimestampBoundReadOnly(TimestampBound)
Creates transaction options with the given timestampBound
options.
Declaration
public static SpannerTransactionCreationOptions ForTimestampBoundReadOnly(TimestampBound timestampBound)
Parameters
Type | 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)
Creates transaction options with the given transactionId
.
Declaration
public static SpannerTransactionCreationOptions FromReadOnlyTransactionId(TransactionId transactionId)
Parameters
Type | Name | Description |
---|---|---|
TransactionId | transactionId | The transaction ID to use for the transaction. Must not be null. |
Returns
Type | Description |
---|---|
SpannerTransactionCreationOptions |
WithExcludeFromChangeStreams(bool)
Returns a new instance identical to this one except for the value of ExcludeFromChangeStreams. ExcludeFromChangeStreams can only be true for read-write transactions.
Declaration
public SpannerTransactionCreationOptions WithExcludeFromChangeStreams(bool excludeFromChangeStreams)
Parameters
Type | Name | Description |
---|---|---|
bool | excludeFromChangeStreams |
Returns
Type | Description |
---|---|
SpannerTransactionCreationOptions |
WithIsDetached(bool)
Returns a new instance identical to this one except for the value of IsDetached. If TransactionId is set, IsDetached cannot be false.
Declaration
public SpannerTransactionCreationOptions WithIsDetached(bool isDetached)
Parameters
Type | Name | Description |
---|---|---|
bool | isDetached |
Returns
Type | Description |
---|---|
SpannerTransactionCreationOptions |
WithIsSingleUse(bool)
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.
Declaration
public SpannerTransactionCreationOptions WithIsSingleUse(bool isSingleUse)
Parameters
Type | Name | Description |
---|---|---|
bool | isSingleUse |
Returns
Type | Description |
---|---|
SpannerTransactionCreationOptions |