public abstract class DatastoreClient
Datastore client wrapper, for convenient use.
Derived Types
Namespace
Google.Cloud.Datastore.V1Assembly
Google.Cloud.Datastore.V1.dll
Remarks
Each RPC normalizes the partition IDs of the keys in its input entities, and always returns entities with keys with normalized partition IDs. This applies to all keys and entities, including those in values, except keys with both an empty path and an empty or unset partition ID. Normalization of input keys sets the project ID (if not already set) to the project ID from the request.
Properties
DefaultEndpoint
public static string DefaultEndpoint { get; }
The default endpoint for the Datastore service, which is a host of "datastore.googleapis.com" and a port of 443.
Property Value | |
---|---|
Type | Description |
String |
DefaultScopes
public static IReadOnlyList<string> DefaultScopes { get; }
The default Datastore scopes.
Property Value | |
---|---|
Type | Description |
IReadOnlyList<String> |
The default Datastore scopes are:
GrpcClient
public virtual Datastore.DatastoreClient GrpcClient { get; }
The underlying gRPC Datastore client
Property Value | |
---|---|
Type | Description |
Datastore.DatastoreClient |
ServiceMetadata
public static ServiceMetadata ServiceMetadata { get; }
The service metadata associated with this client type.
Property Value | |
---|---|
Type | Description |
ServiceMetadata |
Methods
AllocateIds(AllocateIdsRequest, CallSettings)
public virtual AllocateIdsResponse AllocateIds(AllocateIdsRequest request, CallSettings callSettings = null)
Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
Parameters | |
---|---|
Name | Description |
request | AllocateIdsRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
AllocateIdsResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
AllocateIdsRequest request = new AllocateIdsRequest
{
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
AllocateIdsResponse response = datastoreClient.AllocateIds(request);
AllocateIds(String, IEnumerable<Key>, CallSettings)
public virtual AllocateIdsResponse AllocateIds(string projectId, IEnumerable<Key> keys, CallSettings callSettings = null)
Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
keys | IEnumerable<Key> Required. A list of keys with incomplete key paths for which to allocate IDs. No key may be reserved/read-only. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
AllocateIdsResponse | The RPC response. |
DatastoreClient client = DatastoreClient.Create();
KeyFactory keyFactory = new KeyFactory(projectId, namespaceId, "message");
AllocateIdsResponse response = client.AllocateIds(projectId,
new[] { keyFactory.CreateIncompleteKey(), keyFactory.CreateIncompleteKey() }
);
Entity entity1 = new Entity { Key = response.Keys[0], ["text"] = "Text 1" };
Entity entity2 = new Entity { Key = response.Keys[1], ["text"] = "Text 2" };
AllocateIdsAsync(AllocateIdsRequest, CallSettings)
public virtual Task<AllocateIdsResponse> AllocateIdsAsync(AllocateIdsRequest request, CallSettings callSettings = null)
Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
Parameters | |
---|---|
Name | Description |
request | AllocateIdsRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<AllocateIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
AllocateIdsRequest request = new AllocateIdsRequest
{
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
AllocateIdsResponse response = await datastoreClient.AllocateIdsAsync(request);
AllocateIdsAsync(AllocateIdsRequest, CancellationToken)
public virtual Task<AllocateIdsResponse> AllocateIdsAsync(AllocateIdsRequest request, CancellationToken cancellationToken)
Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
Parameters | |
---|---|
Name | Description |
request | AllocateIdsRequest The request object containing all of the parameters for the API call. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<AllocateIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
AllocateIdsRequest request = new AllocateIdsRequest
{
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
AllocateIdsResponse response = await datastoreClient.AllocateIdsAsync(request);
AllocateIdsAsync(String, IEnumerable<Key>, CallSettings)
public virtual Task<AllocateIdsResponse> AllocateIdsAsync(string projectId, IEnumerable<Key> keys, CallSettings callSettings = null)
Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
keys | IEnumerable<Key> Required. A list of keys with incomplete key paths for which to allocate IDs. No key may be reserved/read-only. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<AllocateIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
IEnumerable<Key> keys = new Key[] { new Key(), };
// Make the request
AllocateIdsResponse response = await datastoreClient.AllocateIdsAsync(projectId, keys);
AllocateIdsAsync(String, IEnumerable<Key>, CancellationToken)
public virtual Task<AllocateIdsResponse> AllocateIdsAsync(string projectId, IEnumerable<Key> keys, CancellationToken cancellationToken)
Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
keys | IEnumerable<Key> Required. A list of keys with incomplete key paths for which to allocate IDs. No key may be reserved/read-only. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<AllocateIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
IEnumerable<Key> keys = new Key[] { new Key(), };
// Make the request
AllocateIdsResponse response = await datastoreClient.AllocateIdsAsync(projectId, keys);
BeginTransaction(BeginTransactionRequest, CallSettings)
public virtual BeginTransactionResponse BeginTransaction(BeginTransactionRequest request, CallSettings callSettings = null)
Begins a new transaction.
Parameters | |
---|---|
Name | Description |
request | BeginTransactionRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
BeginTransactionResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
BeginTransactionRequest request = new BeginTransactionRequest
{
ProjectId = "",
DatabaseId = "",
TransactionOptions = new TransactionOptions(),
};
// Make the request
BeginTransactionResponse response = datastoreClient.BeginTransaction(request);
BeginTransaction(String, CallSettings)
public virtual BeginTransactionResponse BeginTransaction(string projectId, CallSettings callSettings = null)
Begins a new transaction.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
BeginTransactionResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
string projectId = "";
// Make the request
BeginTransactionResponse response = datastoreClient.BeginTransaction(projectId);
BeginTransactionAsync(BeginTransactionRequest, CallSettings)
public virtual Task<BeginTransactionResponse> BeginTransactionAsync(BeginTransactionRequest request, CallSettings callSettings = null)
Begins a new transaction.
Parameters | |
---|---|
Name | Description |
request | BeginTransactionRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<BeginTransactionResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
BeginTransactionRequest request = new BeginTransactionRequest
{
ProjectId = "",
DatabaseId = "",
TransactionOptions = new TransactionOptions(),
};
// Make the request
BeginTransactionResponse response = await datastoreClient.BeginTransactionAsync(request);
BeginTransactionAsync(BeginTransactionRequest, CancellationToken)
public virtual Task<BeginTransactionResponse> BeginTransactionAsync(BeginTransactionRequest request, CancellationToken cancellationToken)
Begins a new transaction.
Parameters | |
---|---|
Name | Description |
request | BeginTransactionRequest The request object containing all of the parameters for the API call. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<BeginTransactionResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
BeginTransactionRequest request = new BeginTransactionRequest
{
ProjectId = "",
DatabaseId = "",
TransactionOptions = new TransactionOptions(),
};
// Make the request
BeginTransactionResponse response = await datastoreClient.BeginTransactionAsync(request);
BeginTransactionAsync(String, CallSettings)
public virtual Task<BeginTransactionResponse> BeginTransactionAsync(string projectId, CallSettings callSettings = null)
Begins a new transaction.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<BeginTransactionResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
// Make the request
BeginTransactionResponse response = await datastoreClient.BeginTransactionAsync(projectId);
BeginTransactionAsync(String, CancellationToken)
public virtual Task<BeginTransactionResponse> BeginTransactionAsync(string projectId, CancellationToken cancellationToken)
Begins a new transaction.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<BeginTransactionResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
// Make the request
BeginTransactionResponse response = await datastoreClient.BeginTransactionAsync(projectId);
Commit(CommitRequest, CallSettings)
public virtual CommitResponse Commit(CommitRequest request, CallSettings callSettings = null)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
request | CommitRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
CommitResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
CommitRequest request = new CommitRequest
{
Transaction = ByteString.Empty,
Mode = CommitRequest.Types.Mode.Unspecified,
Mutations = { new Mutation(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
CommitResponse response = datastoreClient.Commit(request);
Commit(String, CommitRequest.Types.Mode, ByteString, IEnumerable<Mutation>, CallSettings)
public virtual CommitResponse Commit(string projectId, CommitRequest.Types.Mode mode, ByteString transaction, IEnumerable<Mutation> mutations, CallSettings callSettings = null)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
mode | CommitRequest.Types.Mode The type of commit to perform. Defaults to |
transaction | ByteString The identifier of the transaction associated with the commit. A transaction identifier is returned by a call to [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. |
mutations | IEnumerable<Mutation> The mutations to perform. When mode is
When mode is |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
CommitResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
string projectId = "";
CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified;
ByteString transaction = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
CommitResponse response = datastoreClient.Commit(projectId, mode, transaction, mutations);
Commit(String, CommitRequest.Types.Mode, IEnumerable<Mutation>, CallSettings)
public virtual CommitResponse Commit(string projectId, CommitRequest.Types.Mode mode, IEnumerable<Mutation> mutations, CallSettings callSettings = null)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
mode | CommitRequest.Types.Mode The type of commit to perform. Defaults to |
mutations | IEnumerable<Mutation> The mutations to perform. When mode is
When mode is |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
CommitResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
string projectId = "";
CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
CommitResponse response = datastoreClient.Commit(projectId, mode, mutations);
CommitAsync(CommitRequest, CallSettings)
public virtual Task<CommitResponse> CommitAsync(CommitRequest request, CallSettings callSettings = null)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
request | CommitRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<CommitResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
CommitRequest request = new CommitRequest
{
Transaction = ByteString.Empty,
Mode = CommitRequest.Types.Mode.Unspecified,
Mutations = { new Mutation(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
CommitResponse response = await datastoreClient.CommitAsync(request);
CommitAsync(CommitRequest, CancellationToken)
public virtual Task<CommitResponse> CommitAsync(CommitRequest request, CancellationToken cancellationToken)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
request | CommitRequest The request object containing all of the parameters for the API call. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<CommitResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
CommitRequest request = new CommitRequest
{
Transaction = ByteString.Empty,
Mode = CommitRequest.Types.Mode.Unspecified,
Mutations = { new Mutation(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
CommitResponse response = await datastoreClient.CommitAsync(request);
CommitAsync(String, CommitRequest.Types.Mode, ByteString, IEnumerable<Mutation>, CallSettings)
public virtual Task<CommitResponse> CommitAsync(string projectId, CommitRequest.Types.Mode mode, ByteString transaction, IEnumerable<Mutation> mutations, CallSettings callSettings = null)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
mode | CommitRequest.Types.Mode The type of commit to perform. Defaults to |
transaction | ByteString The identifier of the transaction associated with the commit. A transaction identifier is returned by a call to [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. |
mutations | IEnumerable<Mutation> The mutations to perform. When mode is
When mode is |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<CommitResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified;
ByteString transaction = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
CommitResponse response = await datastoreClient.CommitAsync(projectId, mode, transaction, mutations);
CommitAsync(String, CommitRequest.Types.Mode, ByteString, IEnumerable<Mutation>, CancellationToken)
public virtual Task<CommitResponse> CommitAsync(string projectId, CommitRequest.Types.Mode mode, ByteString transaction, IEnumerable<Mutation> mutations, CancellationToken cancellationToken)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
mode | CommitRequest.Types.Mode The type of commit to perform. Defaults to |
transaction | ByteString The identifier of the transaction associated with the commit. A transaction identifier is returned by a call to [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. |
mutations | IEnumerable<Mutation> The mutations to perform. When mode is
When mode is |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<CommitResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified;
ByteString transaction = ByteString.Empty;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
CommitResponse response = await datastoreClient.CommitAsync(projectId, mode, transaction, mutations);
CommitAsync(String, CommitRequest.Types.Mode, IEnumerable<Mutation>, CallSettings)
public virtual Task<CommitResponse> CommitAsync(string projectId, CommitRequest.Types.Mode mode, IEnumerable<Mutation> mutations, CallSettings callSettings = null)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
mode | CommitRequest.Types.Mode The type of commit to perform. Defaults to |
mutations | IEnumerable<Mutation> The mutations to perform. When mode is
When mode is |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<CommitResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
CommitResponse response = await datastoreClient.CommitAsync(projectId, mode, mutations);
CommitAsync(String, CommitRequest.Types.Mode, IEnumerable<Mutation>, CancellationToken)
public virtual Task<CommitResponse> CommitAsync(string projectId, CommitRequest.Types.Mode mode, IEnumerable<Mutation> mutations, CancellationToken cancellationToken)
Commits a transaction, optionally creating, deleting or modifying some entities.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
mode | CommitRequest.Types.Mode The type of commit to perform. Defaults to |
mutations | IEnumerable<Mutation> The mutations to perform. When mode is
When mode is |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<CommitResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified;
IEnumerable<Mutation> mutations = new Mutation[] { new Mutation(), };
// Make the request
CommitResponse response = await datastoreClient.CommitAsync(projectId, mode, mutations);
Create()
public static DatastoreClient Create()
Synchronously creates a DatastoreClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use DatastoreClientBuilder.
Returns | |
---|---|
Type | Description |
DatastoreClient | The created DatastoreClient. |
CreateAsync(CancellationToken)
public static Task<DatastoreClient> CreateAsync(CancellationToken cancellationToken = default(CancellationToken))
Asynchronously creates a DatastoreClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use DatastoreClientBuilder.
Parameter | |
---|---|
Name | Description |
cancellationToken | CancellationToken The CancellationToken to use while creating the client. |
Returns | |
---|---|
Type | Description |
Task<DatastoreClient> | The task representing the created DatastoreClient. |
Lookup(LookupRequest, CallSettings)
public virtual LookupResponse Lookup(LookupRequest request, CallSettings callSettings = null)
Looks up entities by key.
Parameters | |
---|---|
Name | Description |
request | LookupRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
LookupResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
LookupRequest request = new LookupRequest
{
ReadOptions = new ReadOptions(),
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
LookupResponse response = datastoreClient.Lookup(request);
Lookup(String, ReadOptions, IEnumerable<Key>, CallSettings)
public virtual LookupResponse Lookup(string projectId, ReadOptions readOptions, IEnumerable<Key> keys, CallSettings callSettings = null)
Looks up entities by key.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
readOptions | ReadOptions The options for this lookup request. |
keys | IEnumerable<Key> Required. Keys of entities to look up. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
LookupResponse | The RPC response. |
KeyFactory keyFactory = new KeyFactory(projectId, namespaceId, "book");
Key key1 = keyFactory.CreateKey("pride_and_prejudice");
Key key2 = keyFactory.CreateKey("not_present");
DatastoreClient client = DatastoreClient.Create();
LookupResponse response = client.Lookup(
projectId,
new ReadOptions { ReadConsistency = ReadConsistency.Strong },
new[] { key1, key2 });
Console.WriteLine($"Found: {response.Found.Count}");
Console.WriteLine($"Deferred: {response.Deferred.Count}");
Console.WriteLine($"Missing: {response.Missing.Count}");
LookupAsync(LookupRequest, CallSettings)
public virtual Task<LookupResponse> LookupAsync(LookupRequest request, CallSettings callSettings = null)
Looks up entities by key.
Parameters | |
---|---|
Name | Description |
request | LookupRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<LookupResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
LookupRequest request = new LookupRequest
{
ReadOptions = new ReadOptions(),
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
LookupResponse response = await datastoreClient.LookupAsync(request);
LookupAsync(LookupRequest, CancellationToken)
public virtual Task<LookupResponse> LookupAsync(LookupRequest request, CancellationToken cancellationToken)
Looks up entities by key.
Parameters | |
---|---|
Name | Description |
request | LookupRequest The request object containing all of the parameters for the API call. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<LookupResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
LookupRequest request = new LookupRequest
{
ReadOptions = new ReadOptions(),
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
LookupResponse response = await datastoreClient.LookupAsync(request);
LookupAsync(String, ReadOptions, IEnumerable<Key>, CallSettings)
public virtual Task<LookupResponse> LookupAsync(string projectId, ReadOptions readOptions, IEnumerable<Key> keys, CallSettings callSettings = null)
Looks up entities by key.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
readOptions | ReadOptions The options for this lookup request. |
keys | IEnumerable<Key> Required. Keys of entities to look up. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<LookupResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
ReadOptions readOptions = new ReadOptions();
IEnumerable<Key> keys = new Key[] { new Key(), };
// Make the request
LookupResponse response = await datastoreClient.LookupAsync(projectId, readOptions, keys);
LookupAsync(String, ReadOptions, IEnumerable<Key>, CancellationToken)
public virtual Task<LookupResponse> LookupAsync(string projectId, ReadOptions readOptions, IEnumerable<Key> keys, CancellationToken cancellationToken)
Looks up entities by key.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
readOptions | ReadOptions The options for this lookup request. |
keys | IEnumerable<Key> Required. Keys of entities to look up. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<LookupResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
ReadOptions readOptions = new ReadOptions();
IEnumerable<Key> keys = new Key[] { new Key(), };
// Make the request
LookupResponse response = await datastoreClient.LookupAsync(projectId, readOptions, keys);
ReserveIds(ReserveIdsRequest, CallSettings)
public virtual ReserveIdsResponse ReserveIds(ReserveIdsRequest request, CallSettings callSettings = null)
Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
Parameters | |
---|---|
Name | Description |
request | ReserveIdsRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
ReserveIdsResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
ReserveIdsRequest request = new ReserveIdsRequest
{
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
ReserveIdsResponse response = datastoreClient.ReserveIds(request);
ReserveIds(String, IEnumerable<Key>, CallSettings)
public virtual ReserveIdsResponse ReserveIds(string projectId, IEnumerable<Key> keys, CallSettings callSettings = null)
Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
keys | IEnumerable<Key> Required. A list of keys with complete key paths whose numeric IDs should not be auto-allocated. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
ReserveIdsResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
string projectId = "";
IEnumerable<Key> keys = new Key[] { new Key(), };
// Make the request
ReserveIdsResponse response = datastoreClient.ReserveIds(projectId, keys);
ReserveIdsAsync(ReserveIdsRequest, CallSettings)
public virtual Task<ReserveIdsResponse> ReserveIdsAsync(ReserveIdsRequest request, CallSettings callSettings = null)
Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
Parameters | |
---|---|
Name | Description |
request | ReserveIdsRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<ReserveIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
ReserveIdsRequest request = new ReserveIdsRequest
{
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
ReserveIdsResponse response = await datastoreClient.ReserveIdsAsync(request);
ReserveIdsAsync(ReserveIdsRequest, CancellationToken)
public virtual Task<ReserveIdsResponse> ReserveIdsAsync(ReserveIdsRequest request, CancellationToken cancellationToken)
Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
Parameters | |
---|---|
Name | Description |
request | ReserveIdsRequest The request object containing all of the parameters for the API call. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<ReserveIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
ReserveIdsRequest request = new ReserveIdsRequest
{
Keys = { new Key(), },
ProjectId = "",
DatabaseId = "",
};
// Make the request
ReserveIdsResponse response = await datastoreClient.ReserveIdsAsync(request);
ReserveIdsAsync(String, IEnumerable<Key>, CallSettings)
public virtual Task<ReserveIdsResponse> ReserveIdsAsync(string projectId, IEnumerable<Key> keys, CallSettings callSettings = null)
Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
keys | IEnumerable<Key> Required. A list of keys with complete key paths whose numeric IDs should not be auto-allocated. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<ReserveIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
IEnumerable<Key> keys = new Key[] { new Key(), };
// Make the request
ReserveIdsResponse response = await datastoreClient.ReserveIdsAsync(projectId, keys);
ReserveIdsAsync(String, IEnumerable<Key>, CancellationToken)
public virtual Task<ReserveIdsResponse> ReserveIdsAsync(string projectId, IEnumerable<Key> keys, CancellationToken cancellationToken)
Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
keys | IEnumerable<Key> Required. A list of keys with complete key paths whose numeric IDs should not be auto-allocated. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<ReserveIdsResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
IEnumerable<Key> keys = new Key[] { new Key(), };
// Make the request
ReserveIdsResponse response = await datastoreClient.ReserveIdsAsync(projectId, keys);
Rollback(RollbackRequest, CallSettings)
public virtual RollbackResponse Rollback(RollbackRequest request, CallSettings callSettings = null)
Rolls back a transaction.
Parameters | |
---|---|
Name | Description |
request | RollbackRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
RollbackResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
RollbackRequest request = new RollbackRequest
{
Transaction = ByteString.Empty,
ProjectId = "",
DatabaseId = "",
};
// Make the request
RollbackResponse response = datastoreClient.Rollback(request);
Rollback(String, ByteString, CallSettings)
public virtual RollbackResponse Rollback(string projectId, ByteString transaction, CallSettings callSettings = null)
Rolls back a transaction.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
transaction | ByteString Required. The transaction identifier, returned by a call to [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
RollbackResponse | The RPC response. |
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
string projectId = "";
ByteString transaction = ByteString.Empty;
// Make the request
RollbackResponse response = datastoreClient.Rollback(projectId, transaction);
RollbackAsync(RollbackRequest, CallSettings)
public virtual Task<RollbackResponse> RollbackAsync(RollbackRequest request, CallSettings callSettings = null)
Rolls back a transaction.
Parameters | |
---|---|
Name | Description |
request | RollbackRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<RollbackResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
RollbackRequest request = new RollbackRequest
{
Transaction = ByteString.Empty,
ProjectId = "",
DatabaseId = "",
};
// Make the request
RollbackResponse response = await datastoreClient.RollbackAsync(request);
RollbackAsync(RollbackRequest, CancellationToken)
public virtual Task<RollbackResponse> RollbackAsync(RollbackRequest request, CancellationToken cancellationToken)
Rolls back a transaction.
Parameters | |
---|---|
Name | Description |
request | RollbackRequest The request object containing all of the parameters for the API call. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<RollbackResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
RollbackRequest request = new RollbackRequest
{
Transaction = ByteString.Empty,
ProjectId = "",
DatabaseId = "",
};
// Make the request
RollbackResponse response = await datastoreClient.RollbackAsync(request);
RollbackAsync(String, ByteString, CallSettings)
public virtual Task<RollbackResponse> RollbackAsync(string projectId, ByteString transaction, CallSettings callSettings = null)
Rolls back a transaction.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
transaction | ByteString Required. The transaction identifier, returned by a call to [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<RollbackResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
ByteString transaction = ByteString.Empty;
// Make the request
RollbackResponse response = await datastoreClient.RollbackAsync(projectId, transaction);
RollbackAsync(String, ByteString, CancellationToken)
public virtual Task<RollbackResponse> RollbackAsync(string projectId, ByteString transaction, CancellationToken cancellationToken)
Rolls back a transaction.
Parameters | |
---|---|
Name | Description |
projectId | String Required. The ID of the project against which to make the request. |
transaction | ByteString Required. The transaction identifier, returned by a call to [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<RollbackResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
ByteString transaction = ByteString.Empty;
// Make the request
RollbackResponse response = await datastoreClient.RollbackAsync(projectId, transaction);
RunQuery(RunQueryRequest, CallSettings)
public virtual RunQueryResponse RunQuery(RunQueryRequest request, CallSettings callSettings = null)
Queries for entities.
Parameters | |
---|---|
Name | Description |
request | RunQueryRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
RunQueryResponse | The RPC response. |
DatastoreClient client = DatastoreClient.Create();
RunQueryRequest request = new RunQueryRequest
{
ProjectId = projectId,
PartitionId = partitionId,
ReadOptions = new ReadOptions { ReadConsistency = ReadConsistency.Eventual },
};
// Structured query
request.Query = new Query("book")
{
Filter = Filter.Equal("author", "Jane Austen")
};
RunQueryResponse response = client.RunQuery(request);
foreach (EntityResult result in response.Batch.EntityResults)
{
Console.WriteLine(result.Entity);
}
// Equivalent GQL query
request.GqlQuery = new GqlQuery
{
QueryString = "SELECT * FROM book WHERE author = @author",
NamedBindings = { { "author", "Jane Austen" } },
};
foreach (EntityResult result in response.Batch.EntityResults)
{
Console.WriteLine(result.Entity);
}
RunQueryAsync(RunQueryRequest, CallSettings)
public virtual Task<RunQueryResponse> RunQueryAsync(RunQueryRequest request, CallSettings callSettings = null)
Queries for entities.
Parameters | |
---|---|
Name | Description |
request | RunQueryRequest The request object containing all of the parameters for the API call. |
callSettings | CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task<RunQueryResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
RunQueryRequest request = new RunQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
Query = new Query(),
ProjectId = "",
DatabaseId = "",
};
// Make the request
RunQueryResponse response = await datastoreClient.RunQueryAsync(request);
RunQueryAsync(RunQueryRequest, CancellationToken)
public virtual Task<RunQueryResponse> RunQueryAsync(RunQueryRequest request, CancellationToken cancellationToken)
Queries for entities.
Parameters | |
---|---|
Name | Description |
request | RunQueryRequest The request object containing all of the parameters for the API call. |
cancellationToken | CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task<RunQueryResponse> | A Task containing the RPC response. |
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
RunQueryRequest request = new RunQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
Query = new Query(),
ProjectId = "",
DatabaseId = "",
};
// Make the request
RunQueryResponse response = await datastoreClient.RunQueryAsync(request);
ShutdownDefaultChannelsAsync()
public static Task ShutdownDefaultChannelsAsync()
Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.
Returns | |
---|---|
Type | Description |
Task | A task representing the asynchronous shutdown operation. |
After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.