4.6.0 (latest) 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.1 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.5.0 2.4.0 2.3.0

    public abstract class FirestoreClient

Reference documentation and code samples for the Firestore v1 API class FirestoreClient.

Firestore client wrapper, for convenient use.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> FirestoreClient

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Derived Types

[FirestoreClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClientImpl)

## Namespace

[Google.Cloud.Firestore.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1)

## Assembly

Google.Cloud.Firestore.V1.dll

## Remarks

The Cloud Firestore service.

Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
document database that simplifies storing, syncing, and querying data for
your mobile, web, and IoT apps at global scale. Its client libraries provide
live synchronization and offline support, while its security features and
integrations with Firebase and Google Cloud Platform accelerate building
truly serverless apps.

## Properties

### DefaultEndpoint

    public static string DefaultEndpoint { get; }

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

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### DefaultScopes

    public static IReadOnlyList<string> DefaultScopes { get; }

The default Firestore scopes.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1https://learn.microsoft.com/dotnet/api/system.string` |   |

**Remarks** The default Firestore scopes are:

- <https://www.googleapis.com/auth/cloud-platform>
- <https://www.googleapis.com/auth/datastore>

### GrpcClient

    public virtual Firestore.FirestoreClient GrpcClient { get; }

The underlying gRPC Firestore client

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Firestorehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Firestore.FirestoreClient` |   |

### LocationsClient

    public virtual LocationsClient LocationsClient { get; }

The [LocationsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Location/latest/Google.Cloud.Location.LocationsClient.html) associated with this client.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Location/latest/Google.Cloud.Location.LocationsClient.html` |   |

### ServiceMetadata

    public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ServiceMetadata.html` |   |

### Settings

    public virtual FirestoreSettings Settings { get; protected set; }

Returns the effective [CallSettings](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html) used for each API call.
This can be used to create a modified instance of [CallSettings](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html) to pass
for a single API request.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreSettings` |   |

## Methods

### BatchGetDocuments(BatchGetDocumentsRequest, CallSettings)

    public virtual FirestoreClient.BatchGetDocumentsStream BatchGetDocuments(BatchGetDocumentsRequest request, CallSettings callSettings = null)

Gets multiple documents.

Documents returned by this method are not guaranteed to be returned in the
same order that they were requested.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BatchGetDocumentsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient.BatchGetDocumentsStream` | The server stream. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    BatchGetDocumentsRequest request = new BatchGetDocumentsRequest
    {
        Database = "",
        Documents = { "", },
        Mask = new DocumentMask(),
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request, returning a streaming response
    using FirestoreClient.BatchGetDocumentsStream response = firestoreClient.BatchGetDocuments(request);

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

### BatchWrite(BatchWriteRequest, CallSettings)

    public virtual BatchWriteResponse BatchWrite(BatchWriteRequest request, CallSettings callSettings = null)

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically
and can apply them out of order. Method does not allow more than one write
per document. Each write succeeds or fails independently. See the
\[BatchWriteResponse\]\[google.firestore.v1.BatchWriteResponse\] for the
success status of each write.

If you require an atomically applied set of writes, use
\[Commit\]\[google.firestore.v1.Firestore.Commit\] instead.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BatchWriteRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BatchWriteResponse` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    BatchWriteRequest request = new BatchWriteRequest
    {
        Database = "",
        Writes = { new Write(), },
        Labels = { { "", "" }, },
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    BatchWriteResponse response = firestoreClient.BatchWrite(request);

### BatchWriteAsync(BatchWriteRequest, CallSettings)

    public virtual Task<BatchWriteResponse> BatchWriteAsync(BatchWriteRequest request, CallSettings callSettings = null)

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically
and can apply them out of order. Method does not allow more than one write
per document. Each write succeeds or fails independently. See the
\[BatchWriteResponse\]\[google.firestore.v1.BatchWriteResponse\] for the
success status of each write.

If you require an atomically applied set of writes, use
\[Commit\]\[google.firestore.v1.Firestore.Commit\] instead.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BatchWriteRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BatchWriteResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    BatchWriteRequest request = new BatchWriteRequest
    {
        Database = "",
        Writes = { new Write(), },
        Labels = { { "", "" }, },
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    BatchWriteResponse response = await firestoreClient.BatchWriteAsync(request);

### BatchWriteAsync(BatchWriteRequest, CancellationToken)

    public virtual Task<BatchWriteResponse> BatchWriteAsync(BatchWriteRequest request, CancellationToken cancellationToken)

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically
and can apply them out of order. Method does not allow more than one write
per document. Each write succeeds or fails independently. See the
\[BatchWriteResponse\]\[google.firestore.v1.BatchWriteResponse\] for the
success status of each write.

If you require an atomically applied set of writes, use
\[Commit\]\[google.firestore.v1.Firestore.Commit\] instead.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BatchWriteRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BatchWriteResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    BatchWriteRequest request = new BatchWriteRequest
    {
        Database = "",
        Writes = { new Write(), },
        Labels = { { "", "" }, },
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    BatchWriteResponse response = await firestoreClient.BatchWriteAsync(request);

### BeginTransaction(BeginTransactionRequest, CallSettings)

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

Starts a new transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionResponse` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    BeginTransactionRequest request = new BeginTransactionRequest
    {
        Database = "",
        Options = new TransactionOptions(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    BeginTransactionResponse response = firestoreClient.BeginTransaction(request);

### BeginTransaction(string, CallSettings)

    public virtual BeginTransactionResponse BeginTransaction(string database, CallSettings callSettings = null)

Starts a new transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionResponse` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    string database = "";
    // Make the request
    BeginTransactionResponse response = firestoreClient.BeginTransaction(database);

### BeginTransactionAsync(BeginTransactionRequest, CallSettings)

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

Starts a new transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    BeginTransactionRequest request = new BeginTransactionRequest
    {
        Database = "",
        Options = new TransactionOptions(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    BeginTransactionResponse response = await firestoreClient.BeginTransactionAsync(request);

### BeginTransactionAsync(BeginTransactionRequest, CancellationToken)

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

Starts a new transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    BeginTransactionRequest request = new BeginTransactionRequest
    {
        Database = "",
        Options = new TransactionOptions(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    BeginTransactionResponse response = await firestoreClient.BeginTransactionAsync(request);

### BeginTransactionAsync(string, CallSettings)

    public virtual Task<BeginTransactionResponse> BeginTransactionAsync(string database, CallSettings callSettings = null)

Starts a new transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string database = "";
    // Make the request
    BeginTransactionResponse response = await firestoreClient.BeginTransactionAsync(database);

### BeginTransactionAsync(string, CancellationToken)

    public virtual Task<BeginTransactionResponse> BeginTransactionAsync(string database, CancellationToken cancellationToken)

Starts a new transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BeginTransactionResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string database = "";
    // Make the request
    BeginTransactionResponse response = await firestoreClient.BeginTransactionAsync(database);

### Commit(CommitRequest, CallSettings)

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

Commits a transaction, while optionally updating documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitResponse` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    CommitRequest request = new CommitRequest
    {
        Database = "",
        Writes = { new Write(), },
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    CommitResponse response = firestoreClient.Commit(request);

### Commit(string, IEnumerable\<Write\>, CallSettings)

    public virtual CommitResponse Commit(string database, IEnumerable<Write> writes, CallSettings callSettings = null)

Commits a transaction, while optionally updating documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `writes` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Write` The writes to apply. Always executed atomically and in order. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitResponse` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    string database = "";
    IEnumerable<Write> writes = new Write[] { new Write(), };
    // Make the request
    CommitResponse response = firestoreClient.Commit(database, writes);

### CommitAsync(CommitRequest, CallSettings)

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

Commits a transaction, while optionally updating documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    CommitRequest request = new CommitRequest
    {
        Database = "",
        Writes = { new Write(), },
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    CommitResponse response = await firestoreClient.CommitAsync(request);

### CommitAsync(CommitRequest, CancellationToken)

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

Commits a transaction, while optionally updating documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    CommitRequest request = new CommitRequest
    {
        Database = "",
        Writes = { new Write(), },
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    CommitResponse response = await firestoreClient.CommitAsync(request);

### CommitAsync(string, IEnumerable\<Write\>, CallSettings)

    public virtual Task<CommitResponse> CommitAsync(string database, IEnumerable<Write> writes, CallSettings callSettings = null)

Commits a transaction, while optionally updating documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `writes` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Write` The writes to apply. Always executed atomically and in order. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string database = "";
    IEnumerable<Write> writes = new Write[] { new Write(), };
    // Make the request
    CommitResponse response = await firestoreClient.CommitAsync(database, writes);

### CommitAsync(string, IEnumerable\<Write\>, CancellationToken)

    public virtual Task<CommitResponse> CommitAsync(string database, IEnumerable<Write> writes, CancellationToken cancellationToken)

Commits a transaction, while optionally updating documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `writes` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Write` The writes to apply. Always executed atomically and in order. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CommitResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string database = "";
    IEnumerable<Write> writes = new Write[] { new Write(), };
    // Make the request
    CommitResponse response = await firestoreClient.CommitAsync(database, writes);

### Create()

    public static FirestoreClient Create()

Synchronously creates a [FirestoreClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient) using the default credentials, endpoint and settings.
To specify custom credentials or other settings, use [FirestoreClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClientBuilder).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient` | The created [FirestoreClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient). |

### CreateAsync(CancellationToken)

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

Asynchronously creates a [FirestoreClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient) using the default credentials, endpoint and settings.
To specify custom credentials or other settings, use [FirestoreClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClientBuilder).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use while creating the client. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient` | The task representing the created [FirestoreClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient). |

### CreateDocument(CreateDocumentRequest, CallSettings)

    public virtual Document CreateDocument(CreateDocumentRequest request, CallSettings callSettings = null)

Creates a new document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CreateDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    CreateDocumentRequest request = new CreateDocumentRequest
    {
        Parent = "",
        CollectionId = "",
        DocumentId = "",
        Document = new Document(),
        Mask = new DocumentMask(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = firestoreClient.CreateDocument(request);

### CreateDocumentAsync(CreateDocumentRequest, CallSettings)

    public virtual Task<Document> CreateDocumentAsync(CreateDocumentRequest request, CallSettings callSettings = null)

Creates a new document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CreateDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    CreateDocumentRequest request = new CreateDocumentRequest
    {
        Parent = "",
        CollectionId = "",
        DocumentId = "",
        Document = new Document(),
        Mask = new DocumentMask(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = await firestoreClient.CreateDocumentAsync(request);

### CreateDocumentAsync(CreateDocumentRequest, CancellationToken)

    public virtual Task<Document> CreateDocumentAsync(CreateDocumentRequest request, CancellationToken cancellationToken)

Creates a new document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.CreateDocumentRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    CreateDocumentRequest request = new CreateDocumentRequest
    {
        Parent = "",
        CollectionId = "",
        DocumentId = "",
        Document = new Document(),
        Mask = new DocumentMask(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = await firestoreClient.CreateDocumentAsync(request);

### DeleteDocument(DeleteDocumentRequest, CallSettings)

    public virtual void DeleteDocument(DeleteDocumentRequest request, CallSettings callSettings = null)

Deletes a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.DeleteDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    DeleteDocumentRequest request = new DeleteDocumentRequest
    {
        Name = "",
        CurrentDocument = new Precondition(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    firestoreClient.DeleteDocument(request);

### DeleteDocument(string, CallSettings)

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

Deletes a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    string name = "";
    // Make the request
    firestoreClient.DeleteDocument(name);

### DeleteDocumentAsync(DeleteDocumentRequest, CallSettings)

    public virtual Task DeleteDocumentAsync(DeleteDocumentRequest request, CallSettings callSettings = null)

Deletes a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.DeleteDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    DeleteDocumentRequest request = new DeleteDocumentRequest
    {
        Name = "",
        CurrentDocument = new Precondition(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    await firestoreClient.DeleteDocumentAsync(request);

### DeleteDocumentAsync(DeleteDocumentRequest, CancellationToken)

    public virtual Task DeleteDocumentAsync(DeleteDocumentRequest request, CancellationToken cancellationToken)

Deletes a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.DeleteDocumentRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    DeleteDocumentRequest request = new DeleteDocumentRequest
    {
        Name = "",
        CurrentDocument = new Precondition(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    await firestoreClient.DeleteDocumentAsync(request);

### DeleteDocumentAsync(string, CallSettings)

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

Deletes a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string name = "";
    // Make the request
    await firestoreClient.DeleteDocumentAsync(name);

### DeleteDocumentAsync(string, CancellationToken)

    public virtual Task DeleteDocumentAsync(string name, CancellationToken cancellationToken)

Deletes a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string name = "";
    // Make the request
    await firestoreClient.DeleteDocumentAsync(name);

### ExecutePipeline(ExecutePipelineRequest, CallSettings)

    public virtual FirestoreClient.ExecutePipelineStream ExecutePipeline(ExecutePipelineRequest request, CallSettings callSettings = null)

Executes a pipeline query.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ExecutePipelineRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient.ExecutePipelineStream` | The server stream. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    ExecutePipelineRequest request = new ExecutePipelineRequest
    {
        Database = "",
        StructuredPipeline = new StructuredPipeline(),
        Transaction = ByteString.Empty,
        AutoCommitTransaction = false,
        RequestOptions = new RequestOptions(),
    };
    // Make the request, returning a streaming response
    using FirestoreClient.ExecutePipelineStream response = firestoreClient.ExecutePipeline(request);

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

### GetDocument(GetDocumentRequest, CallSettings)

    public virtual Document GetDocument(GetDocumentRequest request, CallSettings callSettings = null)

Gets a single document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.GetDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    GetDocumentRequest request = new GetDocumentRequest
    {
        Name = "",
        Mask = new DocumentMask(),
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = firestoreClient.GetDocument(request);

### GetDocumentAsync(GetDocumentRequest, CallSettings)

    public virtual Task<Document> GetDocumentAsync(GetDocumentRequest request, CallSettings callSettings = null)

Gets a single document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.GetDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    GetDocumentRequest request = new GetDocumentRequest
    {
        Name = "",
        Mask = new DocumentMask(),
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = await firestoreClient.GetDocumentAsync(request);

### GetDocumentAsync(GetDocumentRequest, CancellationToken)

    public virtual Task<Document> GetDocumentAsync(GetDocumentRequest request, CancellationToken cancellationToken)

Gets a single document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.GetDocumentRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    GetDocumentRequest request = new GetDocumentRequest
    {
        Name = "",
        Mask = new DocumentMask(),
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = await firestoreClient.GetDocumentAsync(request);

### ListCollectionIds(ListCollectionIdsRequest, CallSettings)

    public virtual PagedEnumerable<ListCollectionIdsResponse, string> ListCollectionIds(ListCollectionIdsRequest request, CallSettings callSettings = null)

Lists all the collection IDs underneath a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListCollectionIdsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListCollectionIdsResponsehttps://learn.microsoft.com/dotnet/api/system.string` | A pageable sequence of [string](https://learn.microsoft.com/dotnet/api/system.string) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    ListCollectionIdsRequest request = new ListCollectionIdsRequest
    {
        Parent = "",
        ReadTime = new Timestamp(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    PagedEnumerable<ListCollectionIdsResponse, string> response = firestoreClient.ListCollectionIds(request);

    // Iterate over all response items, lazily performing RPCs as required
    foreach (string item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    foreach (ListCollectionIdsResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (string item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<string> singlePage = response.ReadPage(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (string item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### ListCollectionIds(string, string, int?, CallSettings)

    public virtual PagedEnumerable<ListCollectionIdsResponse, string> ListCollectionIds(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists all the collection IDs underneath a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The parent document. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` Use `projects/{project_id}/databases/{database_id}/documents` to list top-level collections. |
| `pageToken` | `https://learn.microsoft.com/dotnet/api/system.string` The token returned from the previous request. A value of `null` or an empty string retrieves the first page. |
| `pageSize` | `https://learn.microsoft.com/dotnet/api/system.int32` The size of page to request. The response will not be larger than this, but may be smaller. A value of `null` or `0` uses a server-defined page size. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListCollectionIdsResponsehttps://learn.microsoft.com/dotnet/api/system.string` | A pageable sequence of [string](https://learn.microsoft.com/dotnet/api/system.string) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    string parent = "";
    // Make the request
    PagedEnumerable<ListCollectionIdsResponse, string> response = firestoreClient.ListCollectionIds(parent);

    // Iterate over all response items, lazily performing RPCs as required
    foreach (string item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    foreach (ListCollectionIdsResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (string item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<string> singlePage = response.ReadPage(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (string item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### ListCollectionIdsAsync(ListCollectionIdsRequest, CallSettings)

    public virtual PagedAsyncEnumerable<ListCollectionIdsResponse, string> ListCollectionIdsAsync(ListCollectionIdsRequest request, CallSettings callSettings = null)

Lists all the collection IDs underneath a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListCollectionIdsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListCollectionIdsResponsehttps://learn.microsoft.com/dotnet/api/system.string` | A pageable asynchronous sequence of [string](https://learn.microsoft.com/dotnet/api/system.string) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    ListCollectionIdsRequest request = new ListCollectionIdsRequest
    {
        Parent = "",
        ReadTime = new Timestamp(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    PagedAsyncEnumerable<ListCollectionIdsResponse, string> response = firestoreClient.ListCollectionIdsAsync(request);

    // Iterate over all response items, lazily performing RPCs as required
    await foreach (string item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    await foreach (ListCollectionIdsResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (string item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<string> singlePage = await response.ReadPageAsync(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (string item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### ListCollectionIdsAsync(string, string, int?, CallSettings)

    public virtual PagedAsyncEnumerable<ListCollectionIdsResponse, string> ListCollectionIdsAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists all the collection IDs underneath a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The parent document. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` Use `projects/{project_id}/databases/{database_id}/documents` to list top-level collections. |
| `pageToken` | `https://learn.microsoft.com/dotnet/api/system.string` The token returned from the previous request. A value of `null` or an empty string retrieves the first page. |
| `pageSize` | `https://learn.microsoft.com/dotnet/api/system.int32` The size of page to request. The response will not be larger than this, but may be smaller. A value of `null` or `0` uses a server-defined page size. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListCollectionIdsResponsehttps://learn.microsoft.com/dotnet/api/system.string` | A pageable asynchronous sequence of [string](https://learn.microsoft.com/dotnet/api/system.string) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string parent = "";
    // Make the request
    PagedAsyncEnumerable<ListCollectionIdsResponse, string> response = firestoreClient.ListCollectionIdsAsync(parent);

    // Iterate over all response items, lazily performing RPCs as required
    await foreach (string item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    await foreach (ListCollectionIdsResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (string item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<string> singlePage = await response.ReadPageAsync(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (string item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### ListDocuments(ListDocumentsRequest, CallSettings)

    public virtual PagedEnumerable<ListDocumentsResponse, Document> ListDocuments(ListDocumentsRequest request, CallSettings callSettings = null)

Lists documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListDocumentsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListDocumentsResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A pageable sequence of [Document](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    ListDocumentsRequest request = new ListDocumentsRequest
    {
        Parent = "",
        CollectionId = "",
        OrderBy = "",
        Mask = new DocumentMask(),
        Transaction = ByteString.Empty,
        ShowMissing = false,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    PagedEnumerable<ListDocumentsResponse, Document> response = firestoreClient.ListDocuments(request);

    // Iterate over all response items, lazily performing RPCs as required
    foreach (Document item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    foreach (ListDocumentsResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (Document item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<Document> singlePage = response.ReadPage(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (Document item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### ListDocumentsAsync(ListDocumentsRequest, CallSettings)

    public virtual PagedAsyncEnumerable<ListDocumentsResponse, Document> ListDocumentsAsync(ListDocumentsRequest request, CallSettings callSettings = null)

Lists documents.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListDocumentsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.ListDocumentsResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A pageable asynchronous sequence of [Document](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    ListDocumentsRequest request = new ListDocumentsRequest
    {
        Parent = "",
        CollectionId = "",
        OrderBy = "",
        Mask = new DocumentMask(),
        Transaction = ByteString.Empty,
        ShowMissing = false,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    PagedAsyncEnumerable<ListDocumentsResponse, Document> response = firestoreClient.ListDocumentsAsync(request);

    // Iterate over all response items, lazily performing RPCs as required
    await foreach (Document item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    await foreach (ListDocumentsResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (Document item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<Document> singlePage = await response.ReadPageAsync(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (Document item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### Listen(CallSettings, BidirectionalStreamingSettings)

    public virtual FirestoreClient.ListenStream Listen(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Listens to changes. This method is only available via gRPC or WebChannel
(not REST).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |
| `streamingSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.BidirectionalStreamingSettings.html` If not null, applies streaming overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient.ListenStream` | The client-server stream. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize streaming call, retrieving the stream object
    using FirestoreClient.ListenStream response = firestoreClient.Listen();

    // Sending requests and retrieving responses can be arbitrarily interleaved
    // Exact sequence will depend on client/server behavior

    // Create task to do something with responses from server
    Task responseHandlerTask = Task.Run(async () =>
    {
        // Note that C# 8 code can use await foreach
        AsyncResponseStream<ListenResponse> responseStream = response.GetResponseStream();
        while (await responseStream.MoveNextAsync())
        {
            ListenResponse responseItem = responseStream.Current;
            // Do something with streamed response
        }
        // The response stream has completed
    });

    // Send requests to the server
    bool done = false;
    while (!done)
    {
        // Initialize a request
        ListenRequest request = new ListenRequest
        {
            Database = "",
            AddTarget = new Target(),
            Labels = { { "", "" }, },
            RequestOptions = new RequestOptions(),
        };
        // Stream a request to the server
        await response.WriteAsync(request);
        // Set "done" to true when sending requests is complete
    }

    // Complete writing requests to the stream
    await response.WriteCompleteAsync();
    // Await the response handler
    // This will complete once all server responses have been processed
    await responseHandlerTask;

### PartitionQuery(PartitionQueryRequest, CallSettings)

    public virtual PagedEnumerable<PartitionQueryResponse, Cursor> PartitionQuery(PartitionQueryRequest request, CallSettings callSettings = null)

Partitions a query by returning partition cursors that can be used to run
the query in parallel. The returned partition cursors are split points that
can be used by RunQuery as starting/end points for the query results.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.PartitionQueryRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.PartitionQueryResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Cursor` | A pageable sequence of [Cursor](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Cursor) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    PartitionQueryRequest request = new PartitionQueryRequest
    {
        Parent = "",
        StructuredQuery = new StructuredQuery(),
        PartitionCount = 0L,
        ReadTime = new Timestamp(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    PagedEnumerable<PartitionQueryResponse, Cursor> response = firestoreClient.PartitionQuery(request);

    // Iterate over all response items, lazily performing RPCs as required
    foreach (Cursor item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    foreach (PartitionQueryResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (Cursor item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<Cursor> singlePage = response.ReadPage(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (Cursor item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### PartitionQueryAsync(PartitionQueryRequest, CallSettings)

    public virtual PagedAsyncEnumerable<PartitionQueryResponse, Cursor> PartitionQueryAsync(PartitionQueryRequest request, CallSettings callSettings = null)

Partitions a query by returning partition cursors that can be used to run
the query in parallel. The returned partition cursors are split points that
can be used by RunQuery as starting/end points for the query results.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.PartitionQueryRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.PartitionQueryResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Cursor` | A pageable asynchronous sequence of [Cursor](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Cursor) resources. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    PartitionQueryRequest request = new PartitionQueryRequest
    {
        Parent = "",
        StructuredQuery = new StructuredQuery(),
        PartitionCount = 0L,
        ReadTime = new Timestamp(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    PagedAsyncEnumerable<PartitionQueryResponse, Cursor> response = firestoreClient.PartitionQueryAsync(request);

    // Iterate over all response items, lazily performing RPCs as required
    await foreach (Cursor item in response)
    {
        // Do something with each item
        Console.WriteLine(item);
    }

    // Or iterate over pages (of server-defined size), performing one RPC per page
    await foreach (PartitionQueryResponse page in response.AsRawResponses())
    {
        // Do something with each page of items
        Console.WriteLine("A page of results:");
        foreach (Cursor item in page)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
    }

    // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
    int pageSize = 10;
    Page<Cursor> singlePage = await response.ReadPageAsync(pageSize);
    // Do something with the page of items
    Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
    foreach (Cursor item in singlePage)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
    // Store the pageToken, for when the next page is required.
    string nextPageToken = singlePage.NextPageToken;

### Rollback(RollbackRequest, CallSettings)

    public virtual void Rollback(RollbackRequest request, CallSettings callSettings = null)

Rolls back a transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.RollbackRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    RollbackRequest request = new RollbackRequest
    {
        Database = "",
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    firestoreClient.Rollback(request);

### Rollback(string, ByteString, CallSettings)

    public virtual void Rollback(string database, ByteString transaction, CallSettings callSettings = null)

Rolls back a transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `transaction` | `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ByteString.html` Required. The transaction to roll back. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    string database = "";
    ByteString transaction = ByteString.Empty;
    // Make the request
    firestoreClient.Rollback(database, transaction);

### RollbackAsync(RollbackRequest, CallSettings)

    public virtual Task RollbackAsync(RollbackRequest request, CallSettings callSettings = null)

Rolls back a transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.RollbackRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    RollbackRequest request = new RollbackRequest
    {
        Database = "",
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    await firestoreClient.RollbackAsync(request);

### RollbackAsync(RollbackRequest, CancellationToken)

    public virtual Task RollbackAsync(RollbackRequest request, CancellationToken cancellationToken)

Rolls back a transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.RollbackRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    RollbackRequest request = new RollbackRequest
    {
        Database = "",
        Transaction = ByteString.Empty,
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    await firestoreClient.RollbackAsync(request);

### RollbackAsync(string, ByteString, CallSettings)

    public virtual Task RollbackAsync(string database, ByteString transaction, CallSettings callSettings = null)

Rolls back a transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `transaction` | `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ByteString.html` Required. The transaction to roll back. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string database = "";
    ByteString transaction = ByteString.Empty;
    // Make the request
    await firestoreClient.RollbackAsync(database, transaction);

### RollbackAsync(string, ByteString, CancellationToken)

    public virtual Task RollbackAsync(string database, ByteString transaction, CancellationToken cancellationToken)

Rolls back a transaction.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `transaction` | `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ByteString.html` Required. The transaction to roll back. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    string database = "";
    ByteString transaction = ByteString.Empty;
    // Make the request
    await firestoreClient.RollbackAsync(database, transaction);

### RunAggregationQuery(RunAggregationQueryRequest, CallSettings)

    public virtual FirestoreClient.RunAggregationQueryStream RunAggregationQuery(RunAggregationQueryRequest request, CallSettings callSettings = null)

Runs an aggregation query.

Rather than producing \[Document\]\[google.firestore.v1.Document\] results like
\[Firestore.RunQuery\]\[google.firestore.v1.Firestore.RunQuery\], this API
allows running an aggregation to produce a series of
\[AggregationResult\]\[google.firestore.v1.AggregationResult\] server-side.

High-Level Example:

    -- Return the number of documents in table given a filter.
    SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.RunAggregationQueryRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient.RunAggregationQueryStream` | The server stream. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    RunAggregationQueryRequest request = new RunAggregationQueryRequest
    {
        Parent = "",
        StructuredAggregationQuery = new StructuredAggregationQuery(),
        Transaction = ByteString.Empty,
        ExplainOptions = new ExplainOptions(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request, returning a streaming response
    using FirestoreClient.RunAggregationQueryStream response = firestoreClient.RunAggregationQuery(request);

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

### RunQuery(RunQueryRequest, CallSettings)

    public virtual FirestoreClient.RunQueryStream RunQuery(RunQueryRequest request, CallSettings callSettings = null)

Runs a query.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.RunQueryRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient.RunQueryStream` | The server stream. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    RunQueryRequest request = new RunQueryRequest
    {
        Parent = "",
        StructuredQuery = new StructuredQuery(),
        Transaction = ByteString.Empty,
        ExplainOptions = new ExplainOptions(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request, returning a streaming response
    using FirestoreClient.RunQueryStream response = firestoreClient.RunQuery(request);

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

### ShutdownDefaultChannelsAsync()

    public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient#Google_Cloud_Firestore_V1_FirestoreClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient#Google_Cloud_Firestore_V1_FirestoreClient_CreateAsync_System_Threading_CancellationToken_). Channels which weren't automatically created are not
affected.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task representing the asynchronous shutdown operation. |

**Remarks** After calling this method, further calls to [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient#Google_Cloud_Firestore_V1_FirestoreClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient#Google_Cloud_Firestore_V1_FirestoreClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down
by another call to this method.

### UpdateDocument(Document, DocumentMask, CallSettings)

    public virtual Document UpdateDocument(Document document, DocumentMask updateMask, CallSettings callSettings = null)

Updates or inserts a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `document` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` Required. The updated document. Creates the document if it does not already exist. |
| `updateMask` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.DocumentMask` The fields to update. None of the field paths in the mask may contain a reserved name. If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    Document document = new Document();
    DocumentMask updateMask = new DocumentMask();
    // Make the request
    Document response = firestoreClient.UpdateDocument(document, updateMask);

### UpdateDocument(UpdateDocumentRequest, CallSettings)

    public virtual Document UpdateDocument(UpdateDocumentRequest request, CallSettings callSettings = null)

Updates or inserts a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.UpdateDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | The RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize request argument(s)
    UpdateDocumentRequest request = new UpdateDocumentRequest
    {
        Document = new Document(),
        UpdateMask = new DocumentMask(),
        Mask = new DocumentMask(),
        CurrentDocument = new Precondition(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = firestoreClient.UpdateDocument(request);

### UpdateDocumentAsync(Document, DocumentMask, CallSettings)

    public virtual Task<Document> UpdateDocumentAsync(Document document, DocumentMask updateMask, CallSettings callSettings = null)

Updates or inserts a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `document` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` Required. The updated document. Creates the document if it does not already exist. |
| `updateMask` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.DocumentMask` The fields to update. None of the field paths in the mask may contain a reserved name. If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    Document document = new Document();
    DocumentMask updateMask = new DocumentMask();
    // Make the request
    Document response = await firestoreClient.UpdateDocumentAsync(document, updateMask);

### UpdateDocumentAsync(Document, DocumentMask, CancellationToken)

    public virtual Task<Document> UpdateDocumentAsync(Document document, DocumentMask updateMask, CancellationToken cancellationToken)

Updates or inserts a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `document` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` Required. The updated document. Creates the document if it does not already exist. |
| `updateMask` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.DocumentMask` The fields to update. None of the field paths in the mask may contain a reserved name. If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    Document document = new Document();
    DocumentMask updateMask = new DocumentMask();
    // Make the request
    Document response = await firestoreClient.UpdateDocumentAsync(document, updateMask);

### UpdateDocumentAsync(UpdateDocumentRequest, CallSettings)

    public virtual Task<Document> UpdateDocumentAsync(UpdateDocumentRequest request, CallSettings callSettings = null)

Updates or inserts a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.UpdateDocumentRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    UpdateDocumentRequest request = new UpdateDocumentRequest
    {
        Document = new Document(),
        UpdateMask = new DocumentMask(),
        Mask = new DocumentMask(),
        CurrentDocument = new Precondition(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = await firestoreClient.UpdateDocumentAsync(request);

### UpdateDocumentAsync(UpdateDocumentRequest, CancellationToken)

    public virtual Task<Document> UpdateDocumentAsync(UpdateDocumentRequest request, CancellationToken cancellationToken)

Updates or inserts a document.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.UpdateDocumentRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.Document` | A Task containing the RPC response. |

**Example**

    // Create client
    FirestoreClient firestoreClient = await FirestoreClient.CreateAsync();
    // Initialize request argument(s)
    UpdateDocumentRequest request = new UpdateDocumentRequest
    {
        Document = new Document(),
        UpdateMask = new DocumentMask(),
        Mask = new DocumentMask(),
        CurrentDocument = new Precondition(),
        RequestOptions = new RequestOptions(),
    };
    // Make the request
    Document response = await firestoreClient.UpdateDocumentAsync(request);

### Write(CallSettings, BidirectionalStreamingSettings)

    public virtual FirestoreClient.WriteStream Write(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Streams batches of document updates and deletes, in order. This method is
only available via gRPC or WebChannel (not REST).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |
| `streamingSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.BidirectionalStreamingSettings.html` If not null, applies streaming overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.FirestoreClient.WriteStream` | The client-server stream. |

**Example**

    // Create client
    FirestoreClient firestoreClient = FirestoreClient.Create();
    // Initialize streaming call, retrieving the stream object
    using FirestoreClient.WriteStream response = firestoreClient.Write();

    // Sending requests and retrieving responses can be arbitrarily interleaved
    // Exact sequence will depend on client/server behavior

    // Create task to do something with responses from server
    Task responseHandlerTask = Task.Run(async () =>
    {
        // Note that C# 8 code can use await foreach
        AsyncResponseStream<WriteResponse> responseStream = response.GetResponseStream();
        while (await responseStream.MoveNextAsync())
        {
            WriteResponse responseItem = responseStream.Current;
            // Do something with streamed response
        }
        // The response stream has completed
    });

    // Send requests to the server
    bool done = false;
    while (!done)
    {
        // Initialize a request
        WriteRequest request = new WriteRequest
        {
            Database = "",
            StreamId = "",
            Writes = { new Write(), },
            StreamToken = ByteString.Empty,
            Labels = { { "", "" }, },
            RequestOptions = new RequestOptions(),
        };
        // Stream a request to the server
        await response.WriteAsync(request);
        // Set "done" to true when sending requests is complete
    }

    // Complete writing requests to the stream
    await response.WriteCompleteAsync();
    // Await the response handler
    // This will complete once all server responses have been processed
    await responseHandlerTask;