DynamoDB c#无法使用列表上的添加操作更新项目

DynamoDB c#无法使用列表上的添加操作更新项目,c#,amazon-web-services,amazon-dynamodb,C#,Amazon Web Services,Amazon Dynamodb,我有更新操作,需要将新地图值添加到项目中的地图列表中 AttributeValue mapList = null; foreach (var item in purchasedItems) { mapList = new AttributeValue() { L = purchasedItems.Select(s => new AttributeValue() {M = s.ToAttr

我有更新操作,需要将新地图值添加到项目中的地图列表中

        AttributeValue mapList = null;
        foreach (var item in purchasedItems)
        {
            mapList = new AttributeValue()
                { L = purchasedItems.Select(s => new AttributeValue() {M = s.ToAttributeMap()}).ToList()};
        }

        var response = await client.UpdateItemAsync(new UpdateItemRequest()
                {
                    TableName = Constants.Tables.PaymentData,
                    Key = new Dictionary<string, AttributeValue>()
                    {
                        {
                            Constants.Tables.GeneralColumnNames.PartitionKey,
                            new AttributeValue(id)
                        },
                        {Constants.Tables.GeneralColumnNames.SortKey, new AttributeValue(sortkey)}
                    },
                    ExpressionAttributeValues = new Dictionary<string, AttributeValue>()
                    {
                        {":purchasedItems", mapList}
                    },
                    UpdateExpression = "ADD PurchasedItems :purchasedItems"
                });
但是这个UpdateItemAsync抛出

Amazon.DynamoDBv2.AmazondynamodException:无效的UpdateExpression: 运算符或函数的操作数类型不正确;接线员:添加,, 操作数类型:列表--> Amazon.Runtime.Internal.HttpErrorResponseException:类型的异常 抛出了“Amazon.Runtime.Internal.HttpErrorResponseException”


我做错了什么?

您是否希望在列表中添加新值?您可以使用SET with list_append方法。我不知道c#但我想你可以用它来搜索语法。我试过了,但在c#中,它不允许在
ExpressionAttributeValues
中定义空列表,以防属性还不在项中
    [
        {
            "CurrencyCode": "USD",
            "Price": 100,
            "CreatedAt": "2019-12-19T09:18:35",
            "Code": "123"
        },
        {
            "CurrencyCode": "USD",
            "Price": 100,
            "CreatedAt": "2019-12-19T09:18:35",
            "Code": "124"
        }
    ]