public void DeleteItem(Hashtable State, string TableName, string primaryKeyValue,string RangeKeyValue) { try { if (State["DynamoDBClient"] == null) SetupClient(State); AmazonDynamoDB client = (AmazonDynamoDB)State["DynamoDBClient"]; Table table = Table.LoadTable(client, TableName); DeleteItemOperationConfig config = new DeleteItemOperationConfig { // Return the deleted item. ReturnValues = ReturnValues.AllOldAttributes }; Document document = table.DeleteItem(primaryKeyValue, RangeKeyValue,config); } catch (Exception ex) { string error = ex.Message; } }
internal Document DeleteHelper(Key key, DeleteItemOperationConfig config, bool isAsync) { var currentConfig = config ?? new DeleteItemOperationConfig(); var req = new DeleteItemRequest { TableName = TableName, Key = key }; req.BeforeRequestEvent += isAsync ? new RequestEventHandler(UserAgentRequestEventHandlerAsync) : new RequestEventHandler(UserAgentRequestEventHandlerSync); if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes) { req.ReturnValues = EnumToStringMapper.Convert(currentConfig.ReturnValues); } if (currentConfig.Expected != null) { req.Expected = currentConfig.Expected.ToExpectedAttributeMap(); } var attributes = DDBClient.DeleteItem(req).DeleteItemResult.Attributes; Document ret = null; if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes) { ret = Document.FromAttributeMap(attributes); } return ret; }
/// <summary> /// Delete a document in DynamoDB, identified by hash-and-range primary key, /// using the specified configs. /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config) { return DeleteHelper(MakeKey(hashKey, rangeKey), config, false); }
/// <summary> /// Delete a document in DynamoDB, using specified configs. /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Document document, DeleteItemOperationConfig config) { return DeleteHelper(MakeKey(document), config, false); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="rangeKey">Range key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem /// operation.</returns> public IAsyncResult BeginDeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(hashKey, rangeKey), config, true), callback, state); }
/// <summary> /// Initiates the asynchronous execution of the DeleteItem operation. /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.DeleteItem"/> /// </summary> /// <param name="document">Document to delete.</param> /// <param name="config">Configuration to use.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem /// operation.</returns> public IAsyncResult BeginDeleteItem(Document document, DeleteItemOperationConfig config, AsyncCallback callback, object state) { return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(document), config, true), callback, state); }
/// <summary> /// Delete a document in DynamoDB, identified by a hash primary key, /// using specified configs. /// </summary> /// <param name="hashKey">Hash key element of the document.</param> /// <param name="config">Configuration to use.</param> /// <returns>Null or old attributes, depending on config.</returns> public Document DeleteItem(Primitive hashKey, DeleteItemOperationConfig config) { return DeleteHelper(MakeKey(hashKey, null), config); }