Share via


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

IDocumentClient.ReadUserFeedAsync 方法

定义

重载

ReadUserFeedAsync(String, FeedOptions)

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

ReadUserFeedAsync(Uri, FeedOptions)

在 Azure Cosmos DB 服务中以异步操作的形式读取用户的源 (序列) 。

ReadUserFeedAsync(String, FeedOptions)

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

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.User>> ReadUserFeedAsync (string usersLink, Microsoft.Azure.Documents.Client.FeedOptions options = default);
abstract member ReadUserFeedAsync : string * Microsoft.Azure.Documents.Client.FeedOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.User>>
Public Function ReadUserFeedAsync (usersLink As String, Optional options As FeedOptions = Nothing) As Task(Of FeedResponse(Of User))

参数

usersLink
String

要读取的资源的 SelfLink。 例如 /dbs/db_rid/users/

options
FeedOptions

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

返回

一个 System.Threading.TasksResourceResponse<TResource> ,它包含包装 User 包含读取资源记录的 。

例外

如果未 usersLink 设置 。

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

StatusCode异常原因
404NotFound - 这意味着你尝试读取的资源源不存在。 检查父删除是否正确。
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<User> response = await client.ReadUserFeedAsync("/dbs/db_rid/users/",
                                                    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));

另请参阅

适用于

ReadUserFeedAsync(Uri, FeedOptions)

在 Azure Cosmos DB 服务中以异步操作的形式读取用户的源 (序列) 。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.User>> ReadUserFeedAsync (Uri databaseUri, Microsoft.Azure.Documents.Client.FeedOptions options = default);
abstract member ReadUserFeedAsync : Uri * Microsoft.Azure.Documents.Client.FeedOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.FeedResponse<Microsoft.Azure.Documents.User>>
Public Function ReadUserFeedAsync (databaseUri As Uri, Optional options As FeedOptions = Nothing) As Task(Of FeedResponse(Of User))

参数

databaseUri
Uri

父数据库的 URI。

options
FeedOptions

(可选的) FeedOptions 请求的 。

返回

表示异步操作的服务响应的任务对象。

适用于