Share via


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

DocumentClient.ReadOffersFeedAsync(FeedOptions) 方法

定义

以异步操作的形式从 Azure Cosmos DB 服务读取数据库帐户的 Offer 源 (序列) 。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.Offer>> ReadOffersFeedAsync (Microsoft.Azure.Documents.Client.FeedOptions options = default);
abstract member ReadOffersFeedAsync : Microsoft.Azure.Documents.Client.FeedOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.Offer>>
override this.ReadOffersFeedAsync : Microsoft.Azure.Documents.Client.FeedOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.Offer>>
Public Function ReadOffersFeedAsync (Optional options As FeedOptions = Nothing) As Task(Of FeedResponse(Of Offer))

参数

options
FeedOptions

(可选) 请求的请求选项。

返回

包含 System.Threading.Tasks 的 , ResourceResponse<TResource> 它包装 Offer 包含读取资源记录的 。

实现

例外

此异常可以封装许多不同类型的错误。 若要确定特定错误,请始终查看 StatusCode 属性。 创建文档时可能会获取的一些常见代码包括:

StatusCode异常原因
429TooManyRequests - 这意味着已超出每秒请求单位数。 请参阅 DocumentClientException.RetryAfter 值,了解在重试此操作之前应等待多长时间。

示例

int count = 0;
string continuation = string.Empty;
do
{
    // Read the feed 10 items at a time until there are no more items to read
    FeedResponse<Offer> response = await client.ReadOfferAsync(new FeedOptions
                                                                {
                                                                    MaxItemCount = 10,
                                                                    RequestContinuation = continuation
                                                                });

    // Append the item count
    count += response.Count;

    // Get the continuation so that we know when to stop.
     continuation = response.ResponseContinuation;
} while (!string.IsNullOrEmpty(continuation));

适用于

另请参阅