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"
}
謝謝你,它是個好主意:)這就是我正在尋找的。 –