Share via


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

IDocumentClient.ReadConflictAsync 方法

定义

重载

ReadConflictAsync(Uri, RequestOptions)

Conflict从 Azure Cosmos DB 服务以异步操作的形式读取 。

ReadConflictAsync(String, RequestOptions)

Conflict以异步操作的形式从 Azure Cosmos DB 服务读取 。

ReadConflictAsync(Uri, RequestOptions)

Conflict从 Azure Cosmos DB 服务以异步操作的形式读取 。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Conflict>> ReadConflictAsync (Uri conflictUri, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReadConflictAsync : Uri * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Conflict>>
Public Function ReadConflictAsync (conflictUri As Uri, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Conflict))

参数

conflictUri
Uri

要读取的冲突资源的 URI。

options
RequestOptions

请求的请求选项。

返回

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

例外

如果未 conflictUri 设置 。

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

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

示例

//Reads a Conflict resource where 
// - db_id is the ID property of the Database
// - coll_id is the ID property of the DocumentCollection
// - conflict_id is the ID property of the Conflict you wish to read. 
var conflictLink = UriFactory.CreateConflictUri("db_id", "coll_id", "conflict_id");
Conflict conflict = await client.ReadConflictAsync(conflictLink);

注解

读取资源是从服务获取资源的最有效方法。 如果知道资源的 ID,请执行读取,而不是按 ID 进行查询。

另请参阅

适用于

ReadConflictAsync(String, RequestOptions)

Conflict以异步操作的形式从 Azure Cosmos DB 服务读取 。

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Conflict>> ReadConflictAsync (string conflictLink, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReadConflictAsync : string * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Conflict>>
Public Function ReadConflictAsync (conflictLink As String, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Conflict))

参数

conflictLink
String

指向要读取的冲突的链接。

options
RequestOptions

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

返回

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

例外

如果未 conflictLink 设置 。

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

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

示例

//Reads a Conflict resource from a Database
// - sample_database is the ID of the database
// - sample_collection is the ID of the collection
// - conflict_id is the ID of the conflict to be read
var conflictLink = "/dbs/sample_database/colls/sample_collection/conflicts/conflict_id";
Conflict conflict = await client.ReadConflictAsync(conflictLink);

注解

读取资源是从数据库获取资源的最有效方法。 如果知道资源的 ID,请执行读取,而不是按 ID 进行查询。

显示的示例使用基于 ID 的链接,其中链接由创建资源时使用的 ID 属性组成。 如果愿意, SelfLink 仍然可以使用 Conflict 的 属性。 自链接是由资源标识符 (或_rid属性) 组成的资源的 URI。 基于 ID 的链接和 SelfLink 都将正常工作。 的格式 conflictLink 始终为“/dbs/{db identifier}/colls/{collectioon identifier}/conflicts/{conflict identifier}”,仅 {...} 中的值会根据你希望使用哪种方法来寻址资源而更改。

另请参阅

适用于