public sealed class DatastoreTransactionImpl : DatastoreTransaction, IDisposableReference documentation and code samples for the Google Cloud Datastore v1 API class DatastoreTransactionImpl.
Production implementation of DatastoreTransaction, using a DatastoreClient to implement the operations.
Implements
IDisposableNamespace
Google.Cloud.Datastore.V1Assembly
Google.Cloud.Datastore.V1.dll
Constructors
DatastoreTransactionImpl(DatastoreClient, string, string, ByteString)
public DatastoreTransactionImpl(DatastoreClient client, string projectId, string namespaceId, ByteString transactionId)Constructs a DatastoreTransactionImpl from a client, project ID and transaction ID.
| Parameters | |
|---|---|
| Name | Description |
client |
DatastoreClientThe client to use for Datastore operations. Must not be null. |
projectId |
stringThe ID of the project of the Datastore operations. Must not be null. |
namespaceId |
stringThe ID of the namespace which is combined with |
transactionId |
ByteStringThe transaction obtained by an earlier BeginTransaction(string, CallSettings) or the asynchronous equivalent. Must not be null |
While this can be constructed manually, the expectation is that instances of this class are obtained via BeginTransaction(CallSettings) or BeginTransactionAsync(CallSettings).
DatastoreTransactionImpl(DatastoreClient, string, string, string, ByteString)
public DatastoreTransactionImpl(DatastoreClient client, string projectId, string namespaceId, string databaseId, ByteString transactionId)Constructs a DatastoreTransactionImpl from a client, project ID and transaction ID.
| Parameters | |
|---|---|
| Name | Description |
client |
DatastoreClientThe client to use for Datastore operations. Must not be null. |
projectId |
stringThe ID of the project of the Datastore operations. Must not be null. |
namespaceId |
stringThe ID of the namespace which is combined with |
databaseId |
stringThe ID of the databse which is combined with |
transactionId |
ByteStringThe transaction obtained by an earlier BeginTransaction(string, CallSettings) or the asynchronous equivalent. Must not be null |
While this can be constructed manually, the expectation is that instances of this class are obtained via BeginTransaction(CallSettings) or BeginTransactionAsync(CallSettings).
Properties
TransactionId
public override ByteString TransactionId { get; }The ID of the transaction, used implicitly in operations performed with this object.
| Property Value | |
|---|---|
| Type | Description |
ByteString |
|
Methods
Commit(CallSettings)
public override CommitResponse Commit(CallSettings callSettings = null)Commits all mutations in this transaction.
| Parameter | |
|---|---|
| Name | Description |
callSettings |
CallSettings |
| Returns | |
|---|---|
| Type | Description |
CommitResponse |
The response from the commit operation. This can be used to determine server-allocated keys. |
Any entities with incomplete keys that are assigned keys by this operation will be updated in memory with the server-allocated keys.
Datastore limits the number of entities that can be modified in a Commit operation, and therefore one transaction. When modifying a large number of entities, partition the changes into multiple transactions. See Datastore limits for more details on Datastore limits.
| Exceptions | |
|---|---|
| Type | Description |
InvalidOperationException |
The transaction has already been committed or rolled back. |
CommitAsync(CallSettings)
public override Task<CommitResponse> CommitAsync(CallSettings callSettings = null)Commits all mutations in this transaction asynchronously.
| Parameter | |
|---|---|
| Name | Description |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
TaskCommitResponse |
The response from the commit operation. This can be used to determine server-allocated keys. |
Any entities with incomplete keys that are assigned keys by this operation will be updated in memory with the server-allocated keys.
Datastore limits the number of entities that can be modified in a Commit operation, and therefore one transaction. When modifying a large number of entities, partition the changes into multiple transactions. See Datastore limits for more details on Datastore limits.
| Exceptions | |
|---|---|
| Type | Description |
InvalidOperationException |
The transaction has already been committed or rolled back. |
Delete(IEnumerable<Entity>)
public override void Delete(IEnumerable<Entity> entities)Adds delete operations for all the specified keys to this transaction.
| Parameter | |
|---|---|
| Name | Description |
entities |
IEnumerableEntityThe entities to delete. Must not be null. |
Delete(IEnumerable<Key>)
public override void Delete(IEnumerable<Key> keys)Adds deletion operations for all the specified keys to this transaction.
| Parameter | |
|---|---|
| Name | Description |
keys |
IEnumerableKeyThe keys to delete. Must not be null. |
Dispose()
public override void Dispose()If the transaction has already been committed, this operation is a no-op. Otherwise, it rolls back the transaction.
Insert(IEnumerable<Entity>)
public override void Insert(IEnumerable<Entity> entities)Adds insert operations for all the specified keys to this transaction.
| Parameter | |
|---|---|
| Name | Description |
entities |
IEnumerableEntityThe entities to insert. Must not be null. |
Lookup(IEnumerable<Key>, CallSettings)
public override IReadOnlyList<Entity> Lookup(IEnumerable<Key> keys, CallSettings callSettings = null)Looks up a collection of entities by key.
| Parameters | |
|---|---|
| Name | Description |
keys |
IEnumerableKeyThe keys to look up. Must not be null, and every element must be non-null and refer to a complete key. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
IReadOnlyListEntity |
A collection of entities with the same size as |
This call may perform multiple RPC operations in order to look up all keys.
LookupAsync(IEnumerable<Key>, CallSettings)
public override Task<IReadOnlyList<Entity>> LookupAsync(IEnumerable<Key> keys, CallSettings callSettings = null)Looks up a collection of entities by key asynchronously.
| Parameters | |
|---|---|
| Name | Description |
keys |
IEnumerableKeyThe keys to look up. Must not be null, and every element must be non-null and refer to a complete key. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
TaskIReadOnlyListEntity |
A collection of entities with the same size as |
This call may perform multiple RPC operations in order to look up all keys.
Rollback(CallSettings)
public override RollbackResponse Rollback(CallSettings callSettings = null)Rolls back this transaction.
| Parameter | |
|---|---|
| Name | Description |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
RollbackResponse |
|
This method is rarely useful explicitly; the Dispose() method rolls back the transaction if it
is still active, so a using statement is normally preferable to this.
| Exceptions | |
|---|---|
| Type | Description |
InvalidOperationException |
The transaction has already been committed or rolled back. |
RollbackAsync(CallSettings)
public override Task<RollbackResponse> RollbackAsync(CallSettings callSettings = null)Rolls back this transaction asynchronously.
| Parameter | |
|---|---|
| Name | Description |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
TaskRollbackResponse |
|
This method is rarely useful explicitly; the Dispose() method rolls back the transaction if it
is still active, so a using statement is normally preferable to this.
| Exceptions | |
|---|---|
| Type | Description |
InvalidOperationException |
The transaction has already been committed or rolled back. |
RunAggregationQuery(AggregationQuery, CallSettings)
public override AggregationQueryResults RunAggregationQuery(AggregationQuery query, CallSettings callSettings = null)Runs the given AggregationQuery in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
AggregationQueryThe AggregationQuery to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
AggregationQueryResults |
The result of aggregation query. |
RunAggregationQuery(DatastoreQuery, CallSettings)
public override AggregationQueryResults RunAggregationQuery(DatastoreQuery query, CallSettings callSettings = null)Runs the given DatastoreQuery in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
DatastoreQueryThe AggregationQuery to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
AggregationQueryResults |
The result of aggregation query. |
RunAggregationQuery(GqlQuery, CallSettings)
public override AggregationQueryResults RunAggregationQuery(GqlQuery query, CallSettings callSettings = null)Runs the given GqlQuery in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
GqlQueryThe GqlQuery to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
AggregationQueryResults |
The result of aggregation query. |
RunAggregationQueryAsync(AggregationQuery, CallSettings)
public override Task<AggregationQueryResults> RunAggregationQueryAsync(AggregationQuery query, CallSettings callSettings = null)Runs the given AggregationQuery in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
AggregationQueryThe AggregationQuery to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
TaskAggregationQueryResults |
A task representing the asynchronous operation. The result of the task is the result of the aggregation query. |
RunAggregationQueryAsync(DatastoreQuery, CallSettings)
public override Task<AggregationQueryResults> RunAggregationQueryAsync(DatastoreQuery query, CallSettings callSettings = null)Runs the given DatastoreQuery in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
DatastoreQueryThe AggregationQuery to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
TaskAggregationQueryResults |
A task representing the asynchronous operation. The result of the task is the result of the aggregation query. |
RunAggregationQueryAsync(GqlQuery, CallSettings)
public override Task<AggregationQueryResults> RunAggregationQueryAsync(GqlQuery query, CallSettings callSettings = null)Runs the given GqlQuery in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
GqlQueryThe GqlQuery to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
TaskAggregationQueryResults |
A task representing the asynchronous operation. The result of the task is the result of the aggregation query. |
RunQueryLazily(DatastoreQuery, CallSettings)
public override LazyDatastoreQuery RunQueryLazily(DatastoreQuery query, CallSettings callSettings = null)Lazily executes the given structured query in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
DatastoreQueryThe query to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
LazyDatastoreQuery |
A LazyDatastoreQuery representing the the lazy query results. |
Using a transaction ensures that a commit operation will fail if any of the entities returned by this query have been modified while the transaction is active. Note that modifications performed as part of this operation are not reflected in the query results.
The results are requested lazily: no API calls will be made until the application starts iterating over the results. Iterating over the same LazyDatastoreQuery object multiple times will execute the query again, potentially returning different results.
RunQueryLazily(GqlQuery, CallSettings)
public override LazyDatastoreQuery RunQueryLazily(GqlQuery gqlQuery, CallSettings callSettings = null)Lazily executes the given GQL query in this transaction.
| Parameters | |
|---|---|
| Name | Description |
gqlQuery |
GqlQueryThe query to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
LazyDatastoreQuery |
A LazyDatastoreQuery representing the result of the query. |
Using a transaction ensures that a commit operation will fail if any of the entities returned by this query have been modified while the transaction is active. Note that modifications performed as part of this operation are not reflected in the query results.
The results are requested lazily: no API calls will be made until the application starts iterating over the results. Iterating over the same LazyDatastoreQuery object multiple times will execute the query again, potentially returning different results.
RunQueryLazily(Query, CallSettings)
public override LazyDatastoreQuery RunQueryLazily(Query query, CallSettings callSettings = null)Lazily executes the given structured query in this transaction.
| Parameters | |
|---|---|
| Name | Description |
query |
QueryThe query to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
LazyDatastoreQuery |
A LazyDatastoreQuery representing the the lazy query results. |
Using a transaction ensures that a commit operation will fail if any of the entities returned by this query have been modified while the transaction is active. Note that modifications performed as part of this operation are not reflected in the query results.
The results are requested lazily: no API calls will be made until the application starts iterating over the results. Iterating over the same LazyDatastoreQuery object multiple times will execute the query again, potentially returning different results.
RunQueryLazilyAsync(DatastoreQuery, CallSettings)
public override AsyncLazyDatastoreQuery RunQueryLazilyAsync(DatastoreQuery query, CallSettings callSettings = null)Lazily executes the given structured query in this transaction for asynchronous consumption.
| Parameters | |
|---|---|
| Name | Description |
query |
DatastoreQueryThe query to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
AsyncLazyDatastoreQuery |
An AsyncLazyDatastoreQuery representing the result of the query. |
Using a transaction ensures that a commit operation will fail if any of the entities returned by this query have been modified while the transaction is active. Note that modifications performed as part of this operation are not reflected in the query results.
The results are requested lazily: no API calls will be made until the application starts iterating over the results. Iterating over the same LazyDatastoreQuery object multiple times will execute the query again, potentially returning different results.
RunQueryLazilyAsync(GqlQuery, CallSettings)
public override AsyncLazyDatastoreQuery RunQueryLazilyAsync(GqlQuery gqlQuery, CallSettings callSettings = null)Lazily executes the given structured query in this transaction for asynchronous consumption.
| Parameters | |
|---|---|
| Name | Description |
gqlQuery |
GqlQueryThe query to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
AsyncLazyDatastoreQuery |
An AsyncLazyDatastoreQuery representing the result of the query. |
Using a transaction ensures that a commit operation will fail if any of the entities returned by this query have been modified while the transaction is active. Note that modifications performed as part of this operation are not reflected in the query results.
The results are requested lazily: no API calls will be made until the application starts iterating over the results. Iterating over the same LazyDatastoreQuery object multiple times will execute the query again, potentially returning different results.
RunQueryLazilyAsync(Query, CallSettings)
public override AsyncLazyDatastoreQuery RunQueryLazilyAsync(Query query, CallSettings callSettings = null)Lazily executes the given structured query in this transaction for asynchronous consumption.
| Parameters | |
|---|---|
| Name | Description |
query |
QueryThe query to execute. Must not be null. |
callSettings |
CallSettingsIf not null, applies overrides to RPC calls. |
| Returns | |
|---|---|
| Type | Description |
AsyncLazyDatastoreQuery |
An AsyncLazyDatastoreQuery representing the result of the query. |
Using a transaction ensures that a commit operation will fail if any of the entities returned by this query have been modified while the transaction is active. Note that modifications performed as part of this operation are not reflected in the query results.
The results are requested lazily: no API calls will be made until the application starts iterating over the results. Iterating over the same LazyDatastoreQuery object multiple times will execute the query again, potentially returning different results.
Update(IEnumerable<Entity>)
public override void Update(IEnumerable<Entity> entities)Adds update operations for all the specified keys to this transaction.
| Parameter | |
|---|---|
| Name | Description |
entities |
IEnumerableEntityThe entities to update. Must not be null. |
Upsert(IEnumerable<Entity>)
public override void Upsert(IEnumerable<Entity> entities)Adds upsert operations for all the specified keys to this transaction.
| Parameter | |
|---|---|
| Name | Description |
entities |
IEnumerableEntityThe entities to upsert. Must not be null. |