Share via


你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Container.ReadManyItemsAsync<T> 方法

定义

使用 Id 和 PartitionKey 值从容器中读取多个项。

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.FeedResponse<T>> ReadManyItemsAsync<T> (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 ReadManyItemsAsync : System.Collections.Generic.IReadOnlyList<ValueTuple<string, Microsoft.Azure.Cosmos.PartitionKey>> * Microsoft.Azure.Cosmos.ReadManyRequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.FeedResponse<'T>>
Public MustOverride Function ReadManyItemsAsync(Of T) (items As IReadOnlyList(Of ValueTuple(Of String, PartitionKey)), Optional readManyRequestOptions As ReadManyRequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of FeedResponse(Of T))

类型参数

T

参数

readManyRequestOptions
ReadManyRequestOptions

ReadMany 操作的请求选项

cancellationToken
CancellationToken

(表示请求取消的可选) CancellationToken

返回

一个 TaskFeedResponse<T> ,包含包装类型化项的 。

示例

public class ToDoActivity{
    public string id {get; set;}
    public string status {get; set;}
}

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

FeedResponse<ToDoActivity> feedResponse = this.Container.ReadManyItemsAsync<ToDoActivity>(itemList);

注解

ReadManyItemsAsync<T>(IReadOnlyList<ValueTuple<String,PartitionKey>>, ReadManyRequestOptions, CancellationToken) 与使用 IN 语句提取大量独立项的查询相比,在延迟方面执行得更好。

适用于