Container.ReadItemAsync<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Reads a item from the Azure Cosmos service as an asynchronous operation.
public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ItemResponse<T>> ReadItemAsync<T> (string id, Microsoft.Azure.Cosmos.PartitionKey partitionKey, Microsoft.Azure.Cosmos.ItemRequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReadItemAsync : string * Microsoft.Azure.Cosmos.PartitionKey * Microsoft.Azure.Cosmos.ItemRequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ItemResponse<'T>>
Public MustOverride Function ReadItemAsync(Of T) (id As String, partitionKey As PartitionKey, Optional requestOptions As ItemRequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ItemResponse(Of T))
Type Parameters
- T
Parameters
- id
- String
The Cosmos item id
- partitionKey
- PartitionKey
The partition key for the item.
- requestOptions
- ItemRequestOptions
(Optional) The options for the item request.
- cancellationToken
- CancellationToken
(Optional) CancellationToken representing request cancellation.
Returns
A Task containing a ItemResponse<T> which wraps the read resource record.
Examples
public class ToDoActivity{
public string id {get; set;}
public string status {get; set;}
}
ToDoActivity toDoActivity = await this.container.ReadItemAsync<ToDoActivity>("id", new PartitionKey("partitionKey"));
Remarks
Items contain meta data that can be obtained by mapping these meta data attributes to properties in T
. * "_ts": Gets the last modified time stamp associated with the item from the Azure Cosmos DB service. * "_etag": Gets the entity tag associated with the item from the Azure Cosmos DB service. * "ttl": Gets the time to live in seconds of the item in the Azure Cosmos DB service. Note that, this API does not support the usage of IfMatchEtag property at the moment.
Applies to
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應