0
如何使用AWS SDK for C#更新项目?如何更新DynamoDB中列表中的项目?
可以说,我想更新“选定”的值改为“真”时ITEMNAME等于“EQQ”。
我写了这个代码没有成功:在DynamoDB表
request = {
ExpressionAttributeNames = new Dictionary<string, string>()
{
{"#I", "Items"},
{"#lN", item.ItemName}
},
ExpressionAttributeValues = new Dictionary<string, AttributeValue>()
{
{ ":item", new AttributeValue
{ L = new List<AttributeValue> {
{ new AttributeValue
{ M = new Dictionary<string,AttributeValue> {
{ "ListName", new AttributeValue { S = "item.ItemName"} },
{ "Selected", new AttributeValue { BOOL = item.Selected} },
{ "ImageSource", new AttributeValue { S = item.ImageSource} }
}}
}
}}
}
},
UpdateExpression = "SET #I.#lN = :item"
// UpdateExpression = "SET #I = list_append(:item,#I)"
// UpdateExpression = "SET #I = :item"
};
var response = await client.UpdateItemAsync(request);
我的JSON数据遵循以下结构:
{
"Items": [
{
"ImageSource": "checked.png",
"ItemName": "egg",
"Selected": true
},
{
"ImageSource": "checked.png",
"ItemName": "Water",
"Selected": true
}
],
"ListCategory": "Technology",
"ListCreator": "John",
"ListId": "e5a7ec9d-b00c-41f3-958a-84c8c183d702",
"ListName": "Test5",
"UpdateDateTıme": "2017-05-05T21:48:41.833Z"
}
谢谢你,它是个好主意:)这就是我正在寻找的。 –