Google Cloud Spanner v1 API - Class SpannerClient (4.2.0)

Stay organized with collections Save and categorize content based on your preferences.
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
IReadOnlyList<String>
Remarks

GrpcClient

public virtual Spanner.SpannerClient GrpcClient { get; }

The underlying gRPC Spanner client

Property Value
TypeDescription
Spanner.SpannerClient

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 CallSettings used for each API call. This can be used to create a modified instance of CallSettings to pass for a single API request.

Property Value
TypeDescription
SpannerSettings

Methods

BatchCreateSessions(DatabaseName, Int32, 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
databaseDatabaseName

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

sessionCountInt32

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 0;
// Make the request
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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
BatchCreateSessionsRequest request = new BatchCreateSessionsRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    SessionTemplate = new Session(),
    SessionCount = 0,
};
// Make the request
BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(request);

BatchCreateSessions(String, Int32, 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.

sessionCountInt32

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
int sessionCount = 0;
// Make the request
BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(database, sessionCount);

BatchCreateSessionsAsync(DatabaseName, Int32, 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
databaseDatabaseName

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

sessionCountInt32

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
Task<BatchCreateSessionsResponse>

A Task containing the RPC response.

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

BatchCreateSessionsAsync(DatabaseName, Int32, 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
databaseDatabaseName

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

sessionCountInt32

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
Task<BatchCreateSessionsResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 0;
// Make the request
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
Task<BatchCreateSessionsResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
BatchCreateSessionsRequest request = new BatchCreateSessionsRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    SessionTemplate = new Session(),
    SessionCount = 0,
};
// Make the request
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
Task<BatchCreateSessionsResponse>

A Task containing the RPC response.

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

BatchCreateSessionsAsync(String, Int32, 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.

sessionCountInt32

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
Task<BatchCreateSessionsResponse>

A Task containing the RPC response.

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

BatchCreateSessionsAsync(String, Int32, 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.

sessionCountInt32

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
Task<BatchCreateSessionsResponse>

A Task containing the RPC response.

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

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
BeginTransactionRequest request = new BeginTransactionRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Options = new TransactionOptions(),
    RequestOptions = new RequestOptions(),
};
// Make the request
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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
TransactionOptions options = new TransactionOptions();
// Make the request
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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
TransactionOptions options = new TransactionOptions();
// Make the request
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
Task<Transaction>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
BeginTransactionRequest request = new BeginTransactionRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Options = new TransactionOptions(),
    RequestOptions = new RequestOptions(),
};
// Make the request
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
Task<Transaction>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
BeginTransactionRequest request = new BeginTransactionRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Options = new TransactionOptions(),
    RequestOptions = new RequestOptions(),
};
// Make the request
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
Task<Transaction>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
TransactionOptions options = new TransactionOptions();
// Make the request
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
Task<Transaction>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
TransactionOptions options = new TransactionOptions();
// Make the request
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
Task<Transaction>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
TransactionOptions options = new TransactionOptions();
// Make the request
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
Task<Transaction>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
TransactionOptions options = new TransactionOptions();
// Make the request
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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
CommitRequest request = new CommitRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    TransactionId = ByteString.Empty,
    Mutations = { new Mutation(), },
    ReturnCommitStats = false,
    RequestOptions = new RequestOptions(),
};
// Make the request
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.

mutationsIEnumerable<Mutation>

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
TransactionOptions singleUseTransaction = new TransactionOptions();
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
ByteString transactionId = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
TransactionOptions singleUseTransaction = new TransactionOptions();
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
ByteString transactionId = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
CommitRequest request = new CommitRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    TransactionId = ByteString.Empty,
    Mutations = { new Mutation(), },
    ReturnCommitStats = false,
    RequestOptions = new RequestOptions(),
};
// Make the request
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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
CommitRequest request = new CommitRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    TransactionId = ByteString.Empty,
    Mutations = { new Mutation(), },
    ReturnCommitStats = false,
    RequestOptions = new RequestOptions(),
};
// Make the request
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.

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
TransactionOptions singleUseTransaction = new TransactionOptions();
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
TransactionOptions singleUseTransaction = new TransactionOptions();
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
ByteString transactionId = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
ByteString transactionId = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
TransactionOptions singleUseTransaction = new TransactionOptions();
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
TransactionOptions singleUseTransaction = new TransactionOptions();
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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.

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

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

mutationsIEnumerable<Mutation>

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
Task<CommitResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
ByteString transactionId = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
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(CancellationToken))

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
Task<SpannerClient>

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., &quot;SELECT 1&quot;.

Parameters
NameDescription
databaseDatabaseName

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
// Make the request
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., &quot;SELECT 1&quot;.

Parameters
NameDescription
requestCreateSessionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Session

The RPC response.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
CreateSessionRequest request = new CreateSessionRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    Session = new Session(),
};
// Make the request
Session response = spannerClient.CreateSession(request);

CreateSession(String, CallSettings)

public virtual Session CreateSession(string 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., &quot;SELECT 1&quot;.

Parameters
NameDescription
databaseString

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
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
// Make the request
Session response = spannerClient.CreateSession(database);

CreateSessionAsync(DatabaseName, CallSettings)

public virtual Task<Session> CreateSessionAsync(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., &quot;SELECT 1&quot;.

Parameters
NameDescription
databaseDatabaseName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

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

CreateSessionAsync(DatabaseName, CancellationToken)

public virtual Task<Session> CreateSessionAsync(DatabaseName database, CancellationToken cancellationToken)

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., &quot;SELECT 1&quot;.

Parameters
NameDescription
databaseDatabaseName

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

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

CreateSessionAsync(CreateSessionRequest, CallSettings)

public virtual Task<Session> CreateSessionAsync(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., &quot;SELECT 1&quot;.

Parameters
NameDescription
requestCreateSessionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
CreateSessionRequest request = new CreateSessionRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    Session = new Session(),
};
// Make the request
Session response = await spannerClient.CreateSessionAsync(request);

CreateSessionAsync(CreateSessionRequest, CancellationToken)

public virtual Task<Session> CreateSessionAsync(CreateSessionRequest request, CancellationToken cancellationToken)

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., &quot;SELECT 1&quot;.

Parameters
NameDescription
requestCreateSessionRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
CreateSessionRequest request = new CreateSessionRequest
{
    DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
    Session = new Session(),
};
// Make the request
Session response = await spannerClient.CreateSessionAsync(request);

CreateSessionAsync(String, CallSettings)

public virtual Task<Session> CreateSessionAsync(string 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., &quot;SELECT 1&quot;.

Parameters
NameDescription
databaseString

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
// Make the request
Session response = await spannerClient.CreateSessionAsync(database);

CreateSessionAsync(String, CancellationToken)

public virtual Task<Session> CreateSessionAsync(string database, CancellationToken cancellationToken)

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., &quot;SELECT 1&quot;.

Parameters
NameDescription
databaseString

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
// Make the request
Session response = await spannerClient.CreateSessionAsync(database);

DeleteSession(DeleteSessionRequest, CallSettings)

public virtual void DeleteSession(DeleteSessionRequest request, CallSettings callSettings = null)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
requestDeleteSessionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
DeleteSessionRequest request = new DeleteSessionRequest
{
    SessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
};
// Make the request
spannerClient.DeleteSession(request);

DeleteSession(SessionName, CallSettings)

public virtual void DeleteSession(SessionName name, CallSettings callSettings = null)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
nameSessionName

Required. The name of the session to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
SessionName name = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
// Make the request
spannerClient.DeleteSession(name);

DeleteSession(String, CallSettings)

public virtual void DeleteSession(string name, CallSettings callSettings = null)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
nameString

Required. The name of the session to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
// Make the request
spannerClient.DeleteSession(name);

DeleteSessionAsync(DeleteSessionRequest, CallSettings)

public virtual Task DeleteSessionAsync(DeleteSessionRequest request, CallSettings callSettings = null)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
requestDeleteSessionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
DeleteSessionRequest request = new DeleteSessionRequest
{
    SessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
};
// Make the request
await spannerClient.DeleteSessionAsync(request);

DeleteSessionAsync(DeleteSessionRequest, CancellationToken)

public virtual Task DeleteSessionAsync(DeleteSessionRequest request, CancellationToken cancellationToken)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
requestDeleteSessionRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
DeleteSessionRequest request = new DeleteSessionRequest
{
    SessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
};
// Make the request
await spannerClient.DeleteSessionAsync(request);

DeleteSessionAsync(SessionName, CallSettings)

public virtual Task DeleteSessionAsync(SessionName name, CallSettings callSettings = null)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
nameSessionName

Required. The name of the session to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName name = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
// Make the request
await spannerClient.DeleteSessionAsync(name);

DeleteSessionAsync(SessionName, CancellationToken)

public virtual Task DeleteSessionAsync(SessionName name, CancellationToken cancellationToken)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
nameSessionName

Required. The name of the session to delete.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
SessionName name = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
// Make the request
await spannerClient.DeleteSessionAsync(name);

DeleteSessionAsync(String, CallSettings)

public virtual Task DeleteSessionAsync(string name, CallSettings callSettings = null)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
nameString

Required. The name of the session to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
// Make the request
await spannerClient.DeleteSessionAsync(name);

DeleteSessionAsync(String, CancellationToken)

public virtual Task DeleteSessionAsync(string name, CancellationToken cancellationToken)

Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.

Parameters
NameDescription
nameString

Required. The name of the session to delete.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
// Make the request
await spannerClient.DeleteSessionAsync(name);

ExecuteBatchDml(ExecuteBatchDmlRequest, CallSettings)

public virtual ExecuteBatchDmlResponse ExecuteBatchDml(ExecuteBatchDmlRequest request, CallSettings callSettings = null)

Executes a batch of SQL DML statements. This method allows many statements to be run with lower latency than submitting them sequentially with [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].

Statements are executed in sequential order. A request can succeed even if a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the response provides information about the statement that failed. Clients must inspect this field to determine whether an error occurred.

Execution stops after the first failed statement; the remaining statements are not executed.

Parameters
NameDescription
requestExecuteBatchDmlRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
ExecuteBatchDmlResponse

The RPC response.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
ExecuteBatchDmlRequest request = new ExecuteBatchDmlRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Transaction = new TransactionSelector(),
    Statements =
    {
        new ExecuteBatchDmlRequest.Types.Statement(),
    },
    Seqno = 0L,
    RequestOptions = new RequestOptions(),
};
// Make the request
ExecuteBatchDmlResponse response = spannerClient.ExecuteBatchDml(request);

ExecuteBatchDmlAsync(ExecuteBatchDmlRequest, CallSettings)

public virtual Task<ExecuteBatchDmlResponse> ExecuteBatchDmlAsync(ExecuteBatchDmlRequest request, CallSettings callSettings = null)

Executes a batch of SQL DML statements. This method allows many statements to be run with lower latency than submitting them sequentially with [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].

Statements are executed in sequential order. A request can succeed even if a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the response provides information about the statement that failed. Clients must inspect this field to determine whether an error occurred.

Execution stops after the first failed statement; the remaining statements are not executed.

Parameters
NameDescription
requestExecuteBatchDmlRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<ExecuteBatchDmlResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
ExecuteBatchDmlRequest request = new ExecuteBatchDmlRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Transaction = new TransactionSelector(),
    Statements =
    {
        new ExecuteBatchDmlRequest.Types.Statement(),
    },
    Seqno = 0L,
    RequestOptions = new RequestOptions(),
};
// Make the request
ExecuteBatchDmlResponse response = await spannerClient.ExecuteBatchDmlAsync(request);

ExecuteBatchDmlAsync(ExecuteBatchDmlRequest, CancellationToken)

public virtual Task<ExecuteBatchDmlResponse> ExecuteBatchDmlAsync(ExecuteBatchDmlRequest request, CancellationToken cancellationToken)

Executes a batch of SQL DML statements. This method allows many statements to be run with lower latency than submitting them sequentially with [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].

Statements are executed in sequential order. A request can succeed even if a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the response provides information about the statement that failed. Clients must inspect this field to determine whether an error occurred.

Execution stops after the first failed statement; the remaining statements are not executed.

Parameters
NameDescription
requestExecuteBatchDmlRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<ExecuteBatchDmlResponse>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
ExecuteBatchDmlRequest request = new ExecuteBatchDmlRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Transaction = new TransactionSelector(),
    Statements =
    {
        new ExecuteBatchDmlRequest.Types.Statement(),
    },
    Seqno = 0L,
    RequestOptions = new RequestOptions(),
};
// Make the request
ExecuteBatchDmlResponse response = await spannerClient.ExecuteBatchDmlAsync(request);

ExecuteSql(ExecuteSqlRequest, CallSettings)

public virtual ResultSet ExecuteSql(ExecuteSqlRequest request, CallSettings callSettings = null)

Executes an SQL statement, returning all results in a single reply. This method cannot be used to return a result set larger than 10 MiB; if the query yields more data than that, the query fails with a FAILED_PRECONDITION error.

Operations inside read-write transactions might return ABORTED. If this occurs, the application should restart the transaction from the beginning. See [Transaction][google.spanner.v1.Transaction] for more details.

Larger result sets can be fetched in streaming fashion by calling [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead.

Parameters
NameDescription
requestExecuteSqlRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
ResultSet

The RPC response.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
ExecuteSqlRequest request = new ExecuteSqlRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Transaction = new TransactionSelector(),
    Sql = "",
    Params = new Struct(),
    ParamTypes =
    {
        {
            "",
            new gcsv::Type()
        },
    },
    ResumeToken = ByteString.Empty,
    QueryMode = ExecuteSqlRequest.Types.QueryMode.Normal,
    PartitionToken = ByteString.Empty,
    Seqno = 0L,
    QueryOptions = new ExecuteSqlRequest.Types.QueryOptions(),
    RequestOptions = new RequestOptions(),
};
// Make the request
ResultSet response = spannerClient.ExecuteSql(request);

ExecuteSqlAsync(ExecuteSqlRequest, CallSettings)

public virtual Task<ResultSet> ExecuteSqlAsync(ExecuteSqlRequest request, CallSettings callSettings = null)

Executes an SQL statement, returning all results in a single reply. This method cannot be used to return a result set larger than 10 MiB; if the query yields more data than that, the query fails with a FAILED_PRECONDITION error.

Operations inside read-write transactions might return ABORTED. If this occurs, the application should restart the transaction from the beginning. See [Transaction][google.spanner.v1.Transaction] for more details.

Larger result sets can be fetched in streaming fashion by calling [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead.

Parameters
NameDescription
requestExecuteSqlRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<ResultSet>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
ExecuteSqlRequest request = new ExecuteSqlRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Transaction = new TransactionSelector(),
    Sql = "",
    Params = new Struct(),
    ParamTypes =
    {
        {
            "",
            new gcsv::Type()
        },
    },
    ResumeToken = ByteString.Empty,
    QueryMode = ExecuteSqlRequest.Types.QueryMode.Normal,
    PartitionToken = ByteString.Empty,
    Seqno = 0L,
    QueryOptions = new ExecuteSqlRequest.Types.QueryOptions(),
    RequestOptions = new RequestOptions(),
};
// Make the request
ResultSet response = await spannerClient.ExecuteSqlAsync(request);

ExecuteSqlAsync(ExecuteSqlRequest, CancellationToken)

public virtual Task<ResultSet> ExecuteSqlAsync(ExecuteSqlRequest request, CancellationToken cancellationToken)

Executes an SQL statement, returning all results in a single reply. This method cannot be used to return a result set larger than 10 MiB; if the query yields more data than that, the query fails with a FAILED_PRECONDITION error.

Operations inside read-write transactions might return ABORTED. If this occurs, the application should restart the transaction from the beginning. See [Transaction][google.spanner.v1.Transaction] for more details.

Larger result sets can be fetched in streaming fashion by calling [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead.

Parameters
NameDescription
requestExecuteSqlRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<ResultSet>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
ExecuteSqlRequest request = new ExecuteSqlRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Transaction = new TransactionSelector(),
    Sql = "",
    Params = new Struct(),
    ParamTypes =
    {
        {
            "",
            new gcsv::Type()
        },
    },
    ResumeToken = ByteString.Empty,
    QueryMode = ExecuteSqlRequest.Types.QueryMode.Normal,
    PartitionToken = ByteString.Empty,
    Seqno = 0L,
    QueryOptions = new ExecuteSqlRequest.Types.QueryOptions(),
    RequestOptions = new RequestOptions(),
};
// Make the request
ResultSet response = await spannerClient.ExecuteSqlAsync(request);

ExecuteStreamingSql(ExecuteSqlRequest, CallSettings)

public virtual SpannerClient.ExecuteStreamingSqlStream ExecuteStreamingSql(ExecuteSqlRequest request, CallSettings callSettings = null)

Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there is no limit on the size of the returned result set. However, no individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB.

Parameters
NameDescription
requestExecuteSqlRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SpannerClient.ExecuteStreamingSqlStream

The server stream.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
ExecuteSqlRequest request = new ExecuteSqlRequest
{
    SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
    Transaction = new TransactionSelector(),
    Sql = "",
    Params = new Struct(),
    ParamTypes =
    {
        {
            "",
            new gcsv::Type()
        },
    },
    ResumeToken = ByteString.Empty,
    QueryMode = ExecuteSqlRequest.Types.QueryMode.Normal,
    PartitionToken = ByteString.Empty,
    Seqno = 0L,
    QueryOptions = new ExecuteSqlRequest.Types.QueryOptions(),
    RequestOptions = new RequestOptions(),
};
// Make the request, returning a streaming response
SpannerClient.ExecuteStreamingSqlStream response = spannerClient.ExecuteStreamingSql(request);

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

GetSession(GetSessionRequest, CallSettings)

public virtual Session GetSession(GetSessionRequest request, CallSettings callSettings = null)

Gets a session. Returns NOT_FOUND if the session does not exist. This is mainly useful for determining whether a session is still alive.

Parameters
NameDescription
requestGetSessionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Session

The RPC response.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
GetSessionRequest request = new GetSessionRequest
{
    SessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
};
// Make the request
Session response = spannerClient.GetSession(request);

GetSession(SessionName, CallSettings)

public virtual Session GetSession(SessionName name, CallSettings callSettings = null)

Gets a session. Returns NOT_FOUND if the session does not exist. This is mainly useful for determining whether a session is still alive.

Parameters
NameDescription
nameSessionName

Required. The name of the session to retrieve.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Session

The RPC response.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
SessionName name = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
// Make the request
Session response = spannerClient.GetSession(name);

GetSession(String, CallSettings)

public virtual Session GetSession(string name, CallSettings callSettings = null)

Gets a session. Returns NOT_FOUND if the session does not exist. This is mainly useful for determining whether a session is still alive.

Parameters
NameDescription
nameString

Required. The name of the session to retrieve.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Session

The RPC response.

Example
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]/sessions/[SESSION]";
// Make the request
Session response = spannerClient.GetSession(name);

GetSessionAsync(GetSessionRequest, CallSettings)

public virtual Task<Session> GetSessionAsync(GetSessionRequest request, CallSettings callSettings = null)

Gets a session. Returns NOT_FOUND if the session does not exist. This is mainly useful for determining whether a session is still alive.

Parameters
NameDescription
requestGetSessionRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
GetSessionRequest request = new GetSessionRequest
{
    SessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
};
// Make the request
Session response = await spannerClient.GetSessionAsync(request);

GetSessionAsync(GetSessionRequest, CancellationToken)

public virtual Task<Session> GetSessionAsync(GetSessionRequest request, CancellationToken cancellationToken)

Gets a session. Returns NOT_FOUND if the session does not exist. This is mainly useful for determining whether a session is still alive.

Parameters
NameDescription
requestGetSessionRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Session>

A Task containing the RPC response.

Example
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
GetSessionRequest request = new GetSessionRequest
{
    SessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
};
// Make the request
Session response = await spannerClient.GetSessionAsync(request);

GetSessionAsync(SessionName, CallSettings)

public virtual Task<Session> GetSessionAsync(SessionName name, CallSettings callSettings = null)

Gets a session. Returns NOT_FOUND if the session does not exist. This is mainly useful for determining whether a session is still alive.

Parameters