c# - 'AmazonDynamoDBClient.PutItem(PutItemRequest)' 由于其保护级别而无法访问'
问题描述
dynamodb 的新用户并尝试将其与我的 .net 核心集成。
我在以下位置使用了示例: https ://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelDotNetItemsExample.html
下面是示例:
private static string tableName = "ProductCatalog";
private static AmazonDynamoDBClient client = new AmazonDynamoDBClient();
private static void CreateItem()
{
var request = new PutItemRequest
{
TableName = tableName,
Item = new Dictionary<string, AttributeValue>()
{
{ "Id", new AttributeValue {
N = "1000"
}},
{ "Title", new AttributeValue {
S = "Book 201 Title"
}},
{ "ISBN", new AttributeValue {
S = "11-11-11-11"
}},
{ "Authors", new AttributeValue {
SS = new List<string>{"Author1", "Author2" }
}},
{ "Price", new AttributeValue {
N = "20.00"
}},
{ "Dimensions", new AttributeValue {
S = "8.5x11.0x.75"
}},
{ "InPublication", new AttributeValue {
BOOL = false
} }
}
};
client.PutItem(request);
}
但是当我运行代码时,我得到了错误:
Error CS0122 'AmazonDynamoDBClient.PutItem(PutItemRequest)' is inaccessible due to its protection level
Error CS0122 'AmazonDynamoDBClient.GetItem(GetItemRequest)' is inaccessible due to its protection level
and so on for all the request.
这里缺少什么?
谢谢
解决方案
看起来我们必须对.net core 使用异步方法来与 dynamo db 交互。
更多信息请访问:https ://docs.aws.amazon.com/mobile/sdkforxamarin/developerguide/dynamodb-integration-docmodel.html
虽然该链接适用于移动平台,但这是我发现并有效的。
推荐阅读
- angular - 如何根据点击上一页显示不同的图像
- gstreamer - gstreamer:Demux & Remux MKV,保存视频
- ruby-on-rails - 如何在 Ruby on Rails 的下拉菜单中选择选项?
- php - 图像未出现,img base64 解码不起作用
- javascript - 如何 Vue 让输入值 v-model 与 v-bind:value 操作
- python - 仅选择从第一到最后的指定行数或随机选择列的给定值
- javascript - JavaScript 中的正则表达式替换,其中某些部分保持不变
- javascript - 为什么这个本地存储代码不起作用?
- single-sign-on - 带有额外字段的 CAS 5.3 登录屏幕修改
- python - 如果 Python Pandas 中的值介于两次之间,则向单元格添加“1”