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

Container.DeleteItemAsync<T> Method

Definition

Delete a item from the Azure Cosmos service as an asynchronous operation.

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ItemResponse<T>> DeleteItemAsync<T>(string id, Microsoft.Azure.Cosmos.PartitionKey partitionKey, Microsoft.Azure.Cosmos.ItemRequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteItemAsync : string * Microsoft.Azure.Cosmos.PartitionKey * Microsoft.Azure.Cosmos.ItemRequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ItemResponse<'T>>
Public MustOverride Function DeleteItemAsync(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 will contain information about the request issued.

Examples

public class ToDoActivity{
    public string id {get; set;}
    public string status {get; set;}
}

ItemResponse item = await this.container.DeleteItemAsync<ToDoActivity>("id", new PartitionKey("partitionKey"));

Remarks

Resource is always null

Applies to