/// <summary>Snippet for BatchGetDocuments</summary> public async Task BatchGetDocumentsRequestObject() { // Snippet: BatchGetDocuments(BatchGetDocumentsRequest, CallSettings) // Create client FirestoreClient firestoreClient = FirestoreClient.Create(); // Initialize request argument(s) BatchGetDocumentsRequest request = new BatchGetDocumentsRequest { Database = "", Documents = { "", }, Mask = new DocumentMask(), Transaction = ByteString.Empty, }; // Make the request, returning a streaming response 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 // End snippet }
/// <summary>Snippet for BatchGetDocuments</summary> public async Task BatchGetDocuments() { // Snippet: BatchGetDocuments(BatchGetDocumentsRequest,CallSettings) // Create client FirestoreClient firestoreClient = FirestoreClient.Create(); // Initialize request argument BatchGetDocumentsRequest request = new BatchGetDocumentsRequest { Database = new DatabaseRootName("[PROJECT]", "[DATABASE]").ToString(), Documents = { }, }; // Make the request, returning a streaming response FirestoreClient.BatchGetDocumentsStream streamingResponse = firestoreClient.BatchGetDocuments(request); // Read streaming responses from server until complete IAsyncEnumerator <BatchGetDocumentsResponse> responseStream = streamingResponse.ResponseStream; while (await responseStream.MoveNext()) { BatchGetDocumentsResponse response = responseStream.Current; // Do something with streamed response } // The response stream has completed // End snippet }
public async System.Threading.Tasks.Task FSBatchGetDocuments() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Batch Retrieve Documents ::\n"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nAvailable Docments:\n"); ListDocuments(); var batchGetDocumentsRequest = new BatchGetDocumentsRequest(); batchGetDocumentsRequest.Database = Parent; while (true) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\n\nEnter Collection [cities]: "); string collectionId = Console.ReadLine(); if (collectionId == "") { collectionId = "cities"; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Document Name (blank when finished): "); string documentName = Console.ReadLine(); if (documentName != "") { Document doc = null; try { doc = GetDocument(documentName, collectionId); } catch (Grpc.Core.RpcException e) { if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "ERROR: Document " + documentName + " not found, ignoring ..."); } continue; } batchGetDocumentsRequest.Documents.Add(doc.Name); } else { break; } } var batchGetDocumentsResponse = new BatchGetDocumentsResponse(); try { var ret = FsClient.BatchGetDocuments(batchGetDocumentsRequest); var responseStream = ret.ResponseStream; var cancellationToken = new System.Threading.CancellationToken(); while (await responseStream.MoveNext(cancellationToken)) { batchGetDocumentsResponse = responseStream.Current; Utils.ReadDocument(batchGetDocumentsResponse.Found); } } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); return; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nSuccessfully batch retrieved documents!\n"); }