Deletes a single item in a table by primary key. You can perform a conditional delete operation that deletes the item if it exists, or if it has an expected attribute value.
In addition to deleting an item, you can also return the item's attribute values in the same operation, using the ReturnValues parameter.
Unless you specify conditions, the DeleteItem is an idempotent operation; running it multiple times on the same item or attribute does not result in an error response.
Conditional deletes are useful for only deleting items if specific conditions are met. If those conditions are met, DynamoDB performs the delete. Otherwise, the item is not deleted.
 Declaration Syntax
 Declaration Syntax| C# | 
public class DeleteItemRequest : AmazonWebServiceRequest
 Members
 Members| All Members | Constructors | Methods | Properties | ||
| Icon | Member | Description | 
|---|---|---|
|  | DeleteItemRequest()()()() | Initializes a new instance of the DeleteItemRequest class | 
|  | ConditionalOperator | 
            A logical operator to apply to the conditions in the Expected map:  
 Constraints: | 
|  | Equals(Object) | (Inherited from Object.) | 
|  | Expected | 
            A map of attribute/condition pairs. This is the conditional block for the DeleteItem operation. Expected allows you to provide
            an attribute name, and whether or not DynamoDB should check to see if the attribute value already exists; or if the attribute value exists
            and has a particular value before changing it. Each item in Expected represents an attribute name for DynamoDB to check, along with
            the following:  
 | 
|  | GetHashCode()()()() | Serves as a hash function for a particular type. (Inherited from Object.) | 
|  | GetType()()()() | Gets the type of the current instance.(Inherited from Object.) | 
|  | Key | 
            A map of attribute names to AttributeValue objects, representing the primary key of the item to delete.
             
             | 
|  | ReturnConsumedCapacity | 
            If set to TOTAL, the response includes ConsumedCapacity data for tables and indexes. If set to INDEXES, the response
            includes ConsumedCapacity for indexes. If set to NONE (the default), ConsumedCapacity is not included in the response.
             
             Constraints: | 
|  | ReturnItemCollectionMetrics | 
            If set to SIZE, statistics about item collections, if any, that were modified during the operation are returned in the response. If
            set to NONE (the default), no statistics are returned.
             
             Constraints: | 
|  | ReturnValues | 
            Use ReturnValues if you want to get the item attributes as they appeared before they were deleted. For DeleteItem, the valid
            values are:  
 Constraints: | 
|  | TableName | 
            The name of the table from which to delete the item.
             
             Constraints: | 
|  | ToString()()()() | Returns a string that represents the current object.(Inherited from Object.) | 
|  | WithConditionalOperator(String) | Obsolete. 
            Sets the ConditionalOperator property
             | 
|  | WithExpected(array<KeyValuePair<(Of <<'(String, ExpectedAttributeValue>)>>)>[]()[][]) | Obsolete. 
            Adds the KeyValuePairs to the Expected dictionary.
             | 
|  | WithKey(array<KeyValuePair<(Of <<'(String, AttributeValue>)>>)>[]()[][]) | Obsolete. 
            Adds the KeyValuePairs to the Key dictionary.
             | 
|  | WithReturnConsumedCapacity(String) | Obsolete. 
            Sets the ReturnConsumedCapacity property
             | 
|  | WithReturnItemCollectionMetrics(String) | Obsolete. 
            Sets the ReturnItemCollectionMetrics property
             | 
|  | WithReturnValues(String) | Obsolete. 
            Sets the ReturnValues property
             | 
|  | WithTableName(String) | Obsolete. 
            Sets the TableName property
             | 
 Examples
 ExamplesThis example shows how to delete an item in a table.
 CopyDeleteItem sample
CopyDeleteItem sample// Create a client AmazonDynamoDBClient client = new AmazonDynamoDBClient(); // Define item key // Hash-key of the target item is string value "Mark Twain" // Range-key of the target item is string value "The Adventures of Tom Sawyer" Dictionary<string, AttributeValue> key = new Dictionary<string, AttributeValue> { { "Author", new AttributeValue { S = "Mark Twain" } }, { "Title", new AttributeValue { S = "The Adventures of Tom Sawyer" } } }; // Create DeleteItem request DeleteItemRequest request = new DeleteItemRequest { TableName = "SampleTable", Key = key }; // Issue request client.DeleteItem(request);
 Inheritance Hierarchy
 Inheritance Hierarchy| Object | ||
|  | AmazonWebServiceRequest | |
|  | DeleteItemRequest | |
 See Also
 See Also