internal Document DeleteHelper(Key key, DeleteItemOperationConfig config, bool isAsync)
{
var currentConfig = config ?? new DeleteItemOperationConfig();
var req = new DeleteItemRequest
{
TableName = TableName,
Key = key
};
((Amazon.Runtime.Internal.IAmazonWebServiceRequest)req).AddBeforeRequestHandler(isAsync ?
new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
new RequestEventHandler(UserAgentRequestEventHandlerSync)
);
if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
req.ReturnValues = EnumMapper.Convert(currentConfig.ReturnValues);
ValidateConditional(currentConfig);
if (currentConfig.Expected != null)
{
req.Expected = currentConfig.Expected.ToExpectedAttributeMap(Conversion);
}
else if (currentConfig.ExpectedState != null &&
currentConfig.ExpectedState.ExpectedValues != null &&
currentConfig.ExpectedState.ExpectedValues.Count > 0)
{
req.Expected = currentConfig.ExpectedState.ToExpectedAttributeMap(Conversion);
if (req.Expected.Count > 1)
req.ConditionalOperator = EnumMapper.Convert(currentConfig.ExpectedState.ConditionalOperator);
}
else if (currentConfig.ConditionalExpression != null && currentConfig.ConditionalExpression.IsSet)
{
currentConfig.ConditionalExpression.ApplyExpression(req, this.Conversion);
}
var attributes = DDBClient.DeleteItem(req).Attributes;
Document ret = null;
if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes)
{
ret = Document.FromAttributeMap(attributes);
}
return ret;
}