Google Cloud Spanner v1 API - Class SpannerClient (5.0.0-beta01)

public abstract class SpannerClient

Reference documentation and code samples for the Google Cloud Spanner v1 API class SpannerClient.

Spanner client wrapper, for convenient use.

Inheritance

object > SpannerClient

Derived Types

Namespace

Google.Cloud.Spanner.V1

Assembly

Google.Cloud.Spanner.V1.dll

Remarks

Cloud Spanner API

The Cloud Spanner API can be used to manage sessions and execute transactions on data stored in Cloud Spanner databases.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the Spanner service, which is a host of "spanner.googleapis.com" and a port of 443.

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Spanner scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

GrpcClient

public virtual Spanner.SpannerClient GrpcClient { get; }

The underlying gRPC Spanner client

Property Value
TypeDescription
SpannerSpannerClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Settings

public virtual SpannerSettings Settings { get; protected set; }

Returns the effective SpannerSettings used for each API call. This can be used to create a modified instance of SpannerSettings to pass for a single API request.

Property Value
TypeDescription
SpannerSettings

Methods

BatchCreateSessions(DatabaseName, int, CallSettings)

public virtual BatchCreateSessionsResponse BatchCreateSessions(DatabaseName database, int sessionCount, CallSettings callSettings = null)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
databaseGoogle.Cloud.Spanner.Common.V1.DatabaseName

Required. The database in which the new sessions are created.

sessionCountint

Required. The number of sessions to be created in this batch call. The API may return fewer than the requested number of sessions. If a specific number of sessions are desired, the client can make additional calls to BatchCreateSessions (adjusting [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary).

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
BatchCreateSessionsResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 0;
// Make the request
gcsv::BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(database, sessionCount);

BatchCreateSessions(BatchCreateSessionsRequest, CallSettings)

public virtual BatchCreateSessionsResponse BatchCreateSessions(BatchCreateSessionsRequest request, CallSettings callSettings = null)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
requestBatchCreateSessionsRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
BatchCreateSessionsResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::BatchCreateSessionsRequest request = new gcsv::BatchCreateSessionsRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    SessionTemplate = new gcsv::Session(),
    SessionCount = 0,
};
// Make the request
gcsv::BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(request);

BatchCreateSessions(string, int, CallSettings)

public virtual BatchCreateSessionsResponse BatchCreateSessions(string database, int sessionCount, CallSettings callSettings = null)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
databasestring

Required. The database in which the new sessions are created.

sessionCountint

Required. The number of sessions to be created in this batch call. The API may return fewer than the requested number of sessions. If a specific number of sessions are desired, the client can make additional calls to BatchCreateSessions (adjusting [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary).

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
BatchCreateSessionsResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
int sessionCount = 0;
// Make the request
gcsv::BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(database, sessionCount);

BatchCreateSessionsAsync(DatabaseName, int, CallSettings)

public virtual Task<BatchCreateSessionsResponse> BatchCreateSessionsAsync(DatabaseName database, int sessionCount, CallSettings callSettings = null)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
databaseGoogle.Cloud.Spanner.Common.V1.DatabaseName

Required. The database in which the new sessions are created.

sessionCountint

Required. The number of sessions to be created in this batch call. The API may return fewer than the requested number of sessions. If a specific number of sessions are desired, the client can make additional calls to BatchCreateSessions (adjusting [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary).

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskBatchCreateSessionsResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 0;
// Make the request
gcsv::BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(database, sessionCount);

BatchCreateSessionsAsync(DatabaseName, int, CancellationToken)

public virtual Task<BatchCreateSessionsResponse> BatchCreateSessionsAsync(DatabaseName database, int sessionCount, CancellationToken cancellationToken)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
databaseGoogle.Cloud.Spanner.Common.V1.DatabaseName

Required. The database in which the new sessions are created.

sessionCountint

Required. The number of sessions to be created in this batch call. The API may return fewer than the requested number of sessions. If a specific number of sessions are desired, the client can make additional calls to BatchCreateSessions (adjusting [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary).

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskBatchCreateSessionsResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 0;
// Make the request
gcsv::BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(database, sessionCount);

BatchCreateSessionsAsync(BatchCreateSessionsRequest, CallSettings)

public virtual Task<BatchCreateSessionsResponse> BatchCreateSessionsAsync(BatchCreateSessionsRequest request, CallSettings callSettings = null)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
requestBatchCreateSessionsRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskBatchCreateSessionsResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::BatchCreateSessionsRequest request = new gcsv::BatchCreateSessionsRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    SessionTemplate = new gcsv::Session(),
    SessionCount = 0,
};
// Make the request
gcsv::BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(request);

BatchCreateSessionsAsync(BatchCreateSessionsRequest, CancellationToken)

public virtual Task<BatchCreateSessionsResponse> BatchCreateSessionsAsync(BatchCreateSessionsRequest request, CancellationToken cancellationToken)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
requestBatchCreateSessionsRequest

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskBatchCreateSessionsResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::BatchCreateSessionsRequest request = new gcsv::BatchCreateSessionsRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    SessionTemplate = new gcsv::Session(),
    SessionCount = 0,
};
// Make the request
gcsv::BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(request);

BatchCreateSessionsAsync(string, int, CallSettings)

public virtual Task<BatchCreateSessionsResponse> BatchCreateSessionsAsync(string database, int sessionCount, CallSettings callSettings = null)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
databasestring

Required. The database in which the new sessions are created.

sessionCountint

Required. The number of sessions to be created in this batch call. The API may return fewer than the requested number of sessions. If a specific number of sessions are desired, the client can make additional calls to BatchCreateSessions (adjusting [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary).

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskBatchCreateSessionsResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
int sessionCount = 0;
// Make the request
gcsv::BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(database, sessionCount);

BatchCreateSessionsAsync(string, int, CancellationToken)

public virtual Task<BatchCreateSessionsResponse> BatchCreateSessionsAsync(string database, int sessionCount, CancellationToken cancellationToken)

Creates multiple new sessions.

This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.

Parameters
NameDescription
databasestring

Required. The database in which the new sessions are created.

sessionCountint

Required. The number of sessions to be created in this batch call. The API may return fewer than the requested number of sessions. If a specific number of sessions are desired, the client can make additional calls to BatchCreateSessions (adjusting [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary).

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskBatchCreateSessionsResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
int sessionCount = 0;
// Make the request
gcsv::BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(database, sessionCount);

BatchWrite(BatchWriteRequest, CallSettings)

public virtual SpannerClient.BatchWriteStream BatchWrite(BatchWriteRequest request, CallSettings callSettings = null)

Batches the supplied mutation groups in a collection of efficient transactions. All mutations in a group are committed atomically. However, mutations across groups can be committed non-atomically in an unspecified order and thus, they must be independent of each other. Partial failure is possible, i.e., some groups may have been committed successfully, while some may have failed. The results of individual batches are streamed into the response as the batches are applied.

BatchWrite requests are not replay protected, meaning that each mutation group may be applied more than once. Replays of non-idempotent mutations may have undesirable effects. For example, replays of an insert mutation may produce an already exists error or if you use generated or commit timestamp-based keys, it may result in additional rows being added to the mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this issue.

Parameters
NameDescription
requestBatchWriteRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SpannerClientBatchWriteStream

The server stream.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::BatchWriteRequest request = new gcsv::BatchWriteRequest
{
    SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    RequestOptions = new gcsv::RequestOptions(),
    MutationGroups =
    {
        new gcsv::BatchWriteRequest.Types.MutationGroup(),
    },
};
// Make the request, returning a streaming response
using gcsv::SpannerClient.BatchWriteStream response = spannerClient.BatchWrite(request);

// Read streaming responses from server until complete
// Note that C# 8 code can use await foreach
AsyncResponseStream<gcsv::BatchWriteResponse> responseStream = response.GetResponseStream();
while (await responseStream.MoveNextAsync())
{
    gcsv::BatchWriteResponse responseItem = responseStream.Current;
    // Do something with streamed response
}
// The response stream has completed

BatchWrite(SessionName, IEnumerable<MutationGroup>, CallSettings)

public virtual SpannerClient.BatchWriteStream BatchWrite(SessionName session, IEnumerable<BatchWriteRequest.Types.MutationGroup> mutationGroups, CallSettings callSettings = null)

Batches the supplied mutation groups in a collection of efficient transactions. All mutations in a group are committed atomically. However, mutations across groups can be committed non-atomically in an unspecified order and thus, they must be independent of each other. Partial failure is possible, i.e., some groups may have been committed successfully, while some may have failed. The results of individual batches are streamed into the response as the batches are applied.

BatchWrite requests are not replay protected, meaning that each mutation group may be applied more than once. Replays of non-idempotent mutations may have undesirable effects. For example, replays of an insert mutation may produce an already exists error or if you use generated or commit timestamp-based keys, it may result in additional rows being added to the mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this issue.

Parameters
NameDescription
sessionSessionName

Required. The session in which the batch request is to be run.

mutationGroupsIEnumerableBatchWriteRequestTypesMutationGroup

Required. The groups of mutations to be applied.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SpannerClientBatchWriteStream

The server stream.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
IEnumerable<gcsv::BatchWriteRequest.Types.MutationGroup> mutationGroups = new gcsv::BatchWriteRequest.Types.MutationGroup[]
{
    new gcsv::BatchWriteRequest.Types.MutationGroup(),
};
// Make the request, returning a streaming response
using gcsv::SpannerClient.BatchWriteStream response = spannerClient.BatchWrite(session, mutationGroups);

// Read streaming responses from server until complete
// Note that C# 8 code can use await foreach
AsyncResponseStream<gcsv::BatchWriteResponse> responseStream = response.GetResponseStream();
while (await responseStream.MoveNextAsync())
{
    gcsv::BatchWriteResponse responseItem = responseStream.Current;
    // Do something with streamed response
}
// The response stream has completed

BatchWrite(string, IEnumerable<MutationGroup>, CallSettings)

public virtual SpannerClient.BatchWriteStream BatchWrite(string session, IEnumerable<BatchWriteRequest.Types.MutationGroup> mutationGroups, CallSettings callSettings = null)

Batches the supplied mutation groups in a collection of efficient transactions. All mutations in a group are committed atomically. However, mutations across groups can be committed non-atomically in an unspecified order and thus, they must be independent of each other. Partial failure is possible, i.e., some groups may have been committed successfully, while some may have failed. The results of individual batches are streamed into the response as the batches are applied.

BatchWrite requests are not replay protected, meaning that each mutation group may be applied more than once. Replays of non-idempotent mutations may have undesirable effects. For example, replays of an insert mutation may produce an already exists error or if you use generated or commit timestamp-based keys, it may result in additional rows being added to the mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this issue.

Parameters
NameDescription
sessionstring

Required. The session in which the batch request is to be run.

mutationGroupsIEnumerableBatchWriteRequestTypesMutationGroup

Required. The groups of mutations to be applied.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SpannerClientBatchWriteStream

The server stream.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
IEnumerable<gcsv::BatchWriteRequest.Types.MutationGroup> mutationGroups = new gcsv::BatchWriteRequest.Types.MutationGroup[]
{
    new gcsv::BatchWriteRequest.Types.MutationGroup(),
};
// Make the request, returning a streaming response
using gcsv::SpannerClient.BatchWriteStream response = spannerClient.BatchWrite(session, mutationGroups);

// Read streaming responses from server until complete
// Note that C# 8 code can use await foreach
AsyncResponseStream<gcsv::BatchWriteResponse> responseStream = response.GetResponseStream();
while (await responseStream.MoveNextAsync())
{
    gcsv::BatchWriteResponse responseItem = responseStream.Current;
    // Do something with streamed response
}
// The response stream has completed

BeginTransaction(BeginTransactionRequest, CallSettings)

public virtual Transaction BeginTransaction(BeginTransactionRequest request, CallSettings callSettings = null)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
requestBeginTransactionRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Transaction

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::BeginTransactionRequest request = new gcsv::BeginTransactionRequest
{
    SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Options = new gcsv::TransactionOptions(),
    RequestOptions = new gcsv::RequestOptions(),
};
// Make the request
gcsv::Transaction response = spannerClient.BeginTransaction(request);

BeginTransaction(SessionName, TransactionOptions, CallSettings)

public virtual Transaction BeginTransaction(SessionName session, TransactionOptions options, CallSettings callSettings = null)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction runs.

optionsTransactionOptions

Required. Options for the new transaction.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Transaction

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
gcsv::TransactionOptions options = new gcsv::TransactionOptions();
// Make the request
gcsv::Transaction response = spannerClient.BeginTransaction(session, options);

BeginTransaction(string, TransactionOptions, CallSettings)

public virtual Transaction BeginTransaction(string session, TransactionOptions options, CallSettings callSettings = null)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction runs.

optionsTransactionOptions

Required. Options for the new transaction.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Transaction

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
gcsv::TransactionOptions options = new gcsv::TransactionOptions();
// Make the request
gcsv::Transaction response = spannerClient.BeginTransaction(session, options);

BeginTransactionAsync(BeginTransactionRequest, CallSettings)

public virtual Task<Transaction> BeginTransactionAsync(BeginTransactionRequest request, CallSettings callSettings = null)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
requestBeginTransactionRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTransaction

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::BeginTransactionRequest request = new gcsv::BeginTransactionRequest
{
    SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Options = new gcsv::TransactionOptions(),
    RequestOptions = new gcsv::RequestOptions(),
};
// Make the request
gcsv::Transaction response = await spannerClient.BeginTransactionAsync(request);

BeginTransactionAsync(BeginTransactionRequest, CancellationToken)

public virtual Task<Transaction> BeginTransactionAsync(BeginTransactionRequest request, CancellationToken cancellationToken)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
requestBeginTransactionRequest

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTransaction

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::BeginTransactionRequest request = new gcsv::BeginTransactionRequest
{
    SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Options = new gcsv::TransactionOptions(),
    RequestOptions = new gcsv::RequestOptions(),
};
// Make the request
gcsv::Transaction response = await spannerClient.BeginTransactionAsync(request);

BeginTransactionAsync(SessionName, TransactionOptions, CallSettings)

public virtual Task<Transaction> BeginTransactionAsync(SessionName session, TransactionOptions options, CallSettings callSettings = null)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction runs.

optionsTransactionOptions

Required. Options for the new transaction.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTransaction

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
gcsv::TransactionOptions options = new gcsv::TransactionOptions();
// Make the request
gcsv::Transaction response = await spannerClient.BeginTransactionAsync(session, options);

BeginTransactionAsync(SessionName, TransactionOptions, CancellationToken)

public virtual Task<Transaction> BeginTransactionAsync(SessionName session, TransactionOptions options, CancellationToken cancellationToken)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction runs.

optionsTransactionOptions

Required. Options for the new transaction.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTransaction

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
gcsv::TransactionOptions options = new gcsv::TransactionOptions();
// Make the request
gcsv::Transaction response = await spannerClient.BeginTransactionAsync(session, options);

BeginTransactionAsync(string, TransactionOptions, CallSettings)

public virtual Task<Transaction> BeginTransactionAsync(string session, TransactionOptions options, CallSettings callSettings = null)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction runs.

optionsTransactionOptions

Required. Options for the new transaction.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTransaction

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
gcsv::TransactionOptions options = new gcsv::TransactionOptions();
// Make the request
gcsv::Transaction response = await spannerClient.BeginTransactionAsync(session, options);

BeginTransactionAsync(string, TransactionOptions, CancellationToken)

public virtual Task<Transaction> BeginTransactionAsync(string session, TransactionOptions options, CancellationToken cancellationToken)

Begins a new transaction. This step can often be skipped: [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction runs.

optionsTransactionOptions

Required. Options for the new transaction.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTransaction

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
gcsv::TransactionOptions options = new gcsv::TransactionOptions();
// Make the request
gcsv::Transaction response = await spannerClient.BeginTransactionAsync(session, options);

Commit(CommitRequest, CallSettings)

public virtual CommitResponse Commit(CommitRequest request, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
requestCommitRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
CommitResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::CommitRequest request = new gcsv::CommitRequest
{
    SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    TransactionId = ByteString.Empty,
    Mutations =
    {
        new gcsv::Mutation(),
    },
    ReturnCommitStats = false,
    RequestOptions = new gcsv::RequestOptions(),
    MaxCommitDelay = new Duration(),
};
// Make the request
gcsv::CommitResponse response = spannerClient.Commit(request);

Commit(SessionName, TransactionOptions, IEnumerable<Mutation>, CallSettings)

public virtual CommitResponse Commit(SessionName session, TransactionOptions singleUseTransaction, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction to be committed is running.

singleUseTransactionTransactionOptions

Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the CommitRequest is sent to Cloud Spanner more than once (for instance, due to retries in the application, or in the transport library), it is possible that the mutations are executed more than once. If this is undesirable, use [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and [Commit][google.spanner.v1.Spanner.Commit] instead.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
CommitResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
gcsv::TransactionOptions singleUseTransaction = new gcsv::TransactionOptions();
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = spannerClient.Commit(session, singleUseTransaction, mutations);

Commit(SessionName, ByteString, IEnumerable<Mutation>, CallSettings)

public virtual CommitResponse Commit(SessionName session, ByteString transactionId, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction to be committed is running.

transactionIdByteString

Commit a previously-started transaction.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
CommitResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
ByteString transactionId = ByteString.Empty;
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = spannerClient.Commit(session, transactionId, mutations);

Commit(string, TransactionOptions, IEnumerable<Mutation>, CallSettings)

public virtual CommitResponse Commit(string session, TransactionOptions singleUseTransaction, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction to be committed is running.

singleUseTransactionTransactionOptions

Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the CommitRequest is sent to Cloud Spanner more than once (for instance, due to retries in the application, or in the transport library), it is possible that the mutations are executed more than once. If this is undesirable, use [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and [Commit][google.spanner.v1.Spanner.Commit] instead.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
CommitResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
gcsv::TransactionOptions singleUseTransaction = new gcsv::TransactionOptions();
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = spannerClient.Commit(session, singleUseTransaction, mutations);

Commit(string, ByteString, IEnumerable<Mutation>, CallSettings)

public virtual CommitResponse Commit(string session, ByteString transactionId, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction to be committed is running.

transactionIdByteString

Commit a previously-started transaction.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
CommitResponse

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
ByteString transactionId = ByteString.Empty;
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = spannerClient.Commit(session, transactionId, mutations);

CommitAsync(CommitRequest, CallSettings)

public virtual Task<CommitResponse> CommitAsync(CommitRequest request, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
requestCommitRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::CommitRequest request = new gcsv::CommitRequest
{
    SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    TransactionId = ByteString.Empty,
    Mutations =
    {
        new gcsv::Mutation(),
    },
    ReturnCommitStats = false,
    RequestOptions = new gcsv::RequestOptions(),
    MaxCommitDelay = new Duration(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(request);

CommitAsync(CommitRequest, CancellationToken)

public virtual Task<CommitResponse> CommitAsync(CommitRequest request, CancellationToken cancellationToken)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
requestCommitRequest

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::CommitRequest request = new gcsv::CommitRequest
{
    SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    TransactionId = ByteString.Empty,
    Mutations =
    {
        new gcsv::Mutation(),
    },
    ReturnCommitStats = false,
    RequestOptions = new gcsv::RequestOptions(),
    MaxCommitDelay = new Duration(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(request);

CommitAsync(SessionName, TransactionOptions, IEnumerable<Mutation>, CallSettings)

public virtual Task<CommitResponse> CommitAsync(SessionName session, TransactionOptions singleUseTransaction, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction to be committed is running.

singleUseTransactionTransactionOptions

Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the CommitRequest is sent to Cloud Spanner more than once (for instance, due to retries in the application, or in the transport library), it is possible that the mutations are executed more than once. If this is undesirable, use [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and [Commit][google.spanner.v1.Spanner.Commit] instead.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
gcsv::TransactionOptions singleUseTransaction = new gcsv::TransactionOptions();
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, singleUseTransaction, mutations);

CommitAsync(SessionName, TransactionOptions, IEnumerable<Mutation>, CancellationToken)

public virtual Task<CommitResponse> CommitAsync(SessionName session, TransactionOptions singleUseTransaction, IEnumerable<Mutation> mutations, CancellationToken cancellationToken)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction to be committed is running.

singleUseTransactionTransactionOptions

Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the CommitRequest is sent to Cloud Spanner more than once (for instance, due to retries in the application, or in the transport library), it is possible that the mutations are executed more than once. If this is undesirable, use [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and [Commit][google.spanner.v1.Spanner.Commit] instead.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
gcsv::TransactionOptions singleUseTransaction = new gcsv::TransactionOptions();
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, singleUseTransaction, mutations);

CommitAsync(SessionName, ByteString, IEnumerable<Mutation>, CallSettings)

public virtual Task<CommitResponse> CommitAsync(SessionName session, ByteString transactionId, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction to be committed is running.

transactionIdByteString

Commit a previously-started transaction.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
ByteString transactionId = ByteString.Empty;
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, transactionId, mutations);

CommitAsync(SessionName, ByteString, IEnumerable<Mutation>, CancellationToken)

public virtual Task<CommitResponse> CommitAsync(SessionName session, ByteString transactionId, IEnumerable<Mutation> mutations, CancellationToken cancellationToken)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionSessionName

Required. The session in which the transaction to be committed is running.

transactionIdByteString

Commit a previously-started transaction.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
gcsv::SessionName session = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
ByteString transactionId = ByteString.Empty;
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, transactionId, mutations);

CommitAsync(string, TransactionOptions, IEnumerable<Mutation>, CallSettings)

public virtual Task<CommitResponse> CommitAsync(string session, TransactionOptions singleUseTransaction, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction to be committed is running.

singleUseTransactionTransactionOptions

Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the CommitRequest is sent to Cloud Spanner more than once (for instance, due to retries in the application, or in the transport library), it is possible that the mutations are executed more than once. If this is undesirable, use [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and [Commit][google.spanner.v1.Spanner.Commit] instead.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
gcsv::TransactionOptions singleUseTransaction = new gcsv::TransactionOptions();
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, singleUseTransaction, mutations);

CommitAsync(string, TransactionOptions, IEnumerable<Mutation>, CancellationToken)

public virtual Task<CommitResponse> CommitAsync(string session, TransactionOptions singleUseTransaction, IEnumerable<Mutation> mutations, CancellationToken cancellationToken)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction to be committed is running.

singleUseTransactionTransactionOptions

Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the CommitRequest is sent to Cloud Spanner more than once (for instance, due to retries in the application, or in the transport library), it is possible that the mutations are executed more than once. If this is undesirable, use [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and [Commit][google.spanner.v1.Spanner.Commit] instead.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
gcsv::TransactionOptions singleUseTransaction = new gcsv::TransactionOptions();
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, singleUseTransaction, mutations);

CommitAsync(string, ByteString, IEnumerable<Mutation>, CallSettings)

public virtual Task<CommitResponse> CommitAsync(string session, ByteString transactionId, IEnumerable<Mutation> mutations, CallSettings callSettings = null)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction to be committed is running.

transactionIdByteString

Commit a previously-started transaction.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
ByteString transactionId = ByteString.Empty;
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, transactionId, mutations);

CommitAsync(string, ByteString, IEnumerable<Mutation>, CancellationToken)

public virtual Task<CommitResponse> CommitAsync(string session, ByteString transactionId, IEnumerable<Mutation> mutations, CancellationToken cancellationToken)

Commits a transaction. The request includes the mutations to be applied to rows in the database.

Commit might return an ABORTED error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If Commit returns ABORTED, the caller should re-attempt the transaction from the beginning, re-using the same session.

On very rare occasions, Commit might return UNKNOWN. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.

Parameters
NameDescription
sessionstring

Required. The session in which the transaction to be committed is running.

transactionIdByteString

Commit a previously-started transaction.

mutationsIEnumerableMutation

The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskCommitResponse

A Task containing the RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = await gcsv::SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
ByteString transactionId = ByteString.Empty;
IEnumerable<gcsv::Mutation> mutations = new gcsv::Mutation[]
{
    new gcsv::Mutation(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(session, transactionId, mutations);

Create()

public static SpannerClient Create()

Synchronously creates a SpannerClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use SpannerClientBuilder.

Returns
TypeDescription
SpannerClient

The created SpannerClient.

CreateAsync(CancellationToken)

public static Task<SpannerClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a SpannerClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use SpannerClientBuilder.

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskSpannerClient

The task representing the created SpannerClient.

CreateSession(DatabaseName, CallSettings)

public virtual Session CreateSession(DatabaseName database, CallSettings callSettings = null)

Creates a new session. A session can be used to perform transactions that read and/or modify data in a Cloud Spanner database. Sessions are meant to be reused for many consecutive transactions.

Sessions can only execute one transaction at a time. To execute multiple concurrent read-write/write-only transactions, create multiple sessions. Note that standalone reads and queries use a transaction internally, and count toward the one transaction limit.

Active sessions use additional server resources, so it is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner may delete sessions for which no operations are sent for more than an hour. If a session is deleted, requests to it return NOT_FOUND.

Idle sessions can be kept alive by sending a trivial SQL query periodically, e.g., "SELECT 1".

Parameters
NameDescription
databaseGoogle.Cloud.Spanner.Common.V1.DatabaseName

Required. The database in which the new session is created.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Session

The RPC response.

Example
// Create client
gcsv::SpannerClient spannerClient = gcsv::SpannerClient.Create();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
// Make the request
gcsv::Session response = spannerClient.CreateSession(database);

CreateSession(CreateSessionRequest, CallSettings)

public virtual Session CreateSession(CreateSessionRequest request, CallSettings callSettings = null)

Creates a new session. A session can be used to perform transactions that read and/or modify data in a Cloud Spanner database. Sessions are meant to be reused for many consecutive transactions.

Sessions can only execute one transaction at a time. To execute multiple concurrent read-write/write-only transactions, create multiple sessions. Note that standalone reads and queries use a transaction internally, and count toward the one transaction limit.

Active sessions use additional server resources, so it is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner may delete sessions for which no operations are sent for more than an hour. If a session is deleted, requests to it return NOT_FOUND.

Idle sessions can be kept alive by sending a trivial SQL query periodically, e.g., "SELECT 1".

Parameters
NameDescription
request