Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用AWS低级API将空AttributeValue传递到DynamoDb_C#_Amazon Web Services_Amazon Dynamodb_Aws Sdk - Fatal编程技术网

C# 使用AWS低级API将空AttributeValue传递到DynamoDb

C# 使用AWS低级API将空AttributeValue传递到DynamoDb,c#,amazon-web-services,amazon-dynamodb,aws-sdk,C#,Amazon Web Services,Amazon Dynamodb,Aws Sdk,我正试图使用文档中的C#低级API更新DynamoDB表中的一个项 以下是我实现这一目标的尝试: var response = DynamoClientProvider.Current.UpdateItem(new UpdateItemRequest { TableName = "MyTable", Key = {{"TableId", new AttributeValue {S = "12345"}}}, ExpressionAttributeNames = {

我正试图使用文档中的C#低级API更新DynamoDB表中的一个项

以下是我实现这一目标的尝试:

var response = DynamoClientProvider.Current.UpdateItem(new UpdateItemRequest
{
    TableName = "MyTable",
    Key = {{"TableId", new AttributeValue {S = "12345"}}},
    ExpressionAttributeNames =
    {
        {"#T","Timestamp"},
        {"#D","Data"}
        {"#K","MyKey"}
    },
    ExpressionAttributeValues =
    {
        {":Timestamp", new AttributeValue("2016-2-3 00:00:00.000")},
        {":Data", new AttributeValue("some data")}
        {":MyKey", new AttributeValue("some other data")}
    },
    UpdateExpression = "SET #D = :Data, #T = :Timestamp, #K = :MyKey",
    ConditionExpression = "attribute_not_exists (Data)",
    ReturnValues = ReturnValue.ALL_OLD
});
此代码工作正常,但是当
MyKey
为空字符串时会出现问题。当该值为空时,我得到以下错误:

Amazon.DynamoDBv2.AmazondynamodException:ExpressionAttributeValues 包含无效值:提供的AttributeValue为空,必须包含 仅支持密钥的一种数据类型:MyKey

因此,我尝试传入null
AttributeValue
,以便在这种情况下通过将属性设置为以下值来删除该属性:

new AttributeValue{NULL = true}

但是,这会将值设置为
True

的字符串文字,我不确定DynamoDB的类型是否可以为空


如果需要删除属性,请使用“SET#D=:Data,#T=:Timestamp REMOVE#K”

谢谢,这是一个低级API,因此很有意义