Container.ReadManyItemsStreamAsync Methode

Definition

Liest mehrere Elemente aus einem Container mithilfe von Id- und PartitionKey-Werten.

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ResponseMessage> ReadManyItemsStreamAsync (System.Collections.Generic.IReadOnlyList<(string id, Microsoft.Azure.Cosmos.PartitionKey partitionKey)> items, Microsoft.Azure.Cosmos.ReadManyRequestOptions readManyRequestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReadManyItemsStreamAsync : System.Collections.Generic.IReadOnlyList<ValueTuple<string, Microsoft.Azure.Cosmos.PartitionKey>> * Microsoft.Azure.Cosmos.ReadManyRequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ResponseMessage>
Public MustOverride Function ReadManyItemsStreamAsync (items As IReadOnlyList(Of ValueTuple(Of String, PartitionKey)), Optional readManyRequestOptions As ReadManyRequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResponseMessage)

Parameter

items
IReadOnlyList<ValueTuple<String,PartitionKey>>

Liste des Elements. ID und PartitionKey

readManyRequestOptions
ReadManyRequestOptions

Anforderungsoptionen für ReadMany-Vorgang

cancellationToken
CancellationToken

(Optional) CancellationToken stellt den Anforderungsabbruch dar.

Gibt zurück

Ein Task , der ein ResponseMessage enthält, das eine Stream umschließt, die die Antwort enthält.

Beispiele

IReadOnlyList<(string, PartitionKey)> itemList = new List<(string, PartitionKey)>
{
    ("Id1", new PartitionKey("pkValue1")),
    ("Id2", new PartitionKey("pkValue2")),
    ("Id3", new PartitionKey("pkValue3"))
};

using (ResponseMessage response = await this.Container.ReadManyItemsStreamAsync(itemList))
{
    if (!response.IsSuccessStatusCode)
    {
        //Handle and log exception
        return;
    }

    //Read or do other operations with the stream
    using (StreamReader streamReader = new StreamReader(response.Content))
    {
        string content = streamReader.ReadToEndAsync();
    }

}

Hinweise

ReadManyItemsStreamAsync(IReadOnlyList<ValueTuple<String,PartitionKey>>, ReadManyRequestOptions, CancellationToken) soll eine bessere Latenz als eine Abfrage mit IN-Anweisungen ausführen, um eine große Anzahl unabhängiger Elemente abzurufen.

Gilt für: