简体   繁体   中英

Deleting in DynamoDB via c# AWS SDK

Getting the error "One or more errors occurred. (Key attribute MyID must be a Primitive type" when trying to delete from DynamoDB in c#

  foreach (var doc in docs)
                    {
                        Logger.LogInformation($"Deleting docs:");
                        await DynamoDbService.DeleteListFromTableAsync(new List<Document> { doc }, requestData.tableName);
                        Logger.LogInformation($"Deleted Docs.");                        
                    }

The DynamoDbService.DeleteListFromTableAsync runs the batchWrite.AddItemToDelete function on the given doc.

Anyone know why I'm getting this error and how to resolve it?

Without knowing the code behind your custom functions or the model itself, it is difficult to tell. But what the error is telling us is that the key must be a primitive (string, number or binary) value and it is not.

As per the docs,

When you create a table or a secondary index, you must specify the names and data types of each primary key attribute (partition key and sort key). Furthermore, each primary key attribute must be defined as type string, number, or binary.

Check out the AWS docs on Dynamo here

If you could post your model and the underlying code, it would be easier to identify the actual issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM