다음을 통해 공유


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