DocumentClient.ReadDocumentCollectionAsync メソッド

定義

オーバーロード

ReadDocumentCollectionAsync(String, RequestOptions)

DocumentCollection非同期操作として Azure Cosmos DB サービスから を読み取ります。

ReadDocumentCollectionAsync(Uri, RequestOptions)

DocumentCollectionを Azure Cosmos DB サービスから非同期操作として読み取ります。

ReadDocumentCollectionAsync(String, RequestOptions)

DocumentCollection非同期操作として Azure Cosmos DB サービスから を読み取ります。

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

パラメーター

documentCollectionLink
String

読み取る DocumentCollection のリンク。

options
RequestOptions

(省略可能)要求の要求オプション。

戻り値

System.Threading.Tasks読み取りリソース レコードをResourceResponse<TResource>含む をDocumentCollectionラップする を含む 。

実装

例外

が設定されていない場合 documentCollectionLink

この例外は、さまざまな種類のエラーをカプセル化できます。 特定のエラーを特定するには、常に StatusCode プロパティを参照してください。 ドキュメントの作成時に取得できる一般的なコードは次のとおりです。

StatusCode例外の理由
404NotFound - 読み取ろうとしたリソースが存在しなかったことを意味します。
429TooManyRequests - つまり、1 秒あたりの要求ユニット数を超えています。 DocumentClientException.RetryAfter の値を調べ、この操作を再試行する前に待機する必要がある時間を確認します。

//This reads a DocumentCollection record from a database where
// - sample_database is the ID of the database
// - collection_id is the ID of the collection resource to be read
var collLink = "/dbs/sample_database/colls/collection_id";
DocumentCollection coll = await client.ReadDocumentCollectionAsync(collLink);

注釈

リソースの読み取りを行うことは、データベースからリソースを取得する最も効率的な方法です。 リソースの ID がわかっている場合は、ID によるクエリではなく読み取りを行います。

次に示す例では、ID ベースのリンクを使用します。このリンクは、リソースの作成時に使用される ID プロパティで構成されます。 必要に応じて、 SelfLink DocumentCollection の プロパティを引き続き使用できます。 セルフリンクは、リソース識別子 (または _rid プロパティ) で構成されるリソースの URI です。 ID ベースのリンクと SelfLink はどちらも機能します。 の documentCollectionLink 形式は常に "/dbs/{db identifier}/colls/{coll identifier}" であり、リソースのアドレス指定に使用するメソッドに応じて、変更内 {} の値のみが使用されます。

こちらもご覧ください

適用対象

ReadDocumentCollectionAsync(Uri, RequestOptions)

DocumentCollectionを Azure Cosmos DB サービスから非同期操作として読み取ります。

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

パラメーター

documentCollectionUri
Uri

読み取る DocumentCollection リソースへの URI。

options
RequestOptions

要求の要求オプション。

戻り値

System.Threading.Tasks読み取りリソース レコードをResourceResponse<TResource>含む をDocumentCollectionラップする を含む 。

実装

例外

が設定されていない場合 documentCollectionUri

この例外は、さまざまな種類のエラーをカプセル化できます。 特定のエラーを特定するには、常に StatusCode プロパティを参照してください。 ドキュメントの作成時に取得できる一般的なコードは次のとおりです。

StatusCode例外の理由
404NotFound - 読み取ろうとしたリソースが存在しなかったことを意味します。
429TooManyRequests - つまり、1 秒あたりの要求ユニット数を超えています。 DocumentClientException.RetryAfter の値を調べ、この操作を再試行する前に待機する必要がある時間を確認します。

//Reads a Document resource where 
// - db_id is the ID property of the Database
// - coll_id is the ID property of the DocumentCollection you wish to read. 
var collLink = UriFactory.CreateCollectionUri("db_id", "coll_id");
DocumentCollection coll = await client.ReadDocumentCollectionAsync(collLink);

注釈

リソースの読み取りを行うことは、サービスからリソースを取得する最も効率的な方法です。 リソースの ID がわかっている場合は、ID によるクエリではなく読み取りを行います。

こちらもご覧ください

適用対象