简体   繁体   English

通过c#AWS开发工具包在DynamoDB中删除

[英]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# 尝试从c#中的DynamoDB中删除时,收到错误“发生一个或多个错误。(关键属性MyID必须是原始类型”)。

  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. DynamoDbService.DeleteListFromTableAsync在给定文档上运行batchWrite.AddItemToDelete函数。

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 在此处查看Dynamo上的AWS文档

If you could post your model and the underlying code, it would be easier to identify the actual issue. 如果可以发布模型和基础代码,则可以更轻松地确定实际问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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