首页 > 解决方案 > '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.

这里缺少什么?

谢谢

标签: c#amazon-dynamodb

解决方案


看起来我们必须对.net core 使用异步方法来与 dynamo db 交互。

更多信息请访问:https ://docs.aws.amazon.com/mobile/sdkforxamarin/developerguide/dynamodb-integration-docmodel.html

虽然该链接适用于移动平台,但这是我发现并有效的。


推荐阅读