代码之家  ›  专栏  ›  技术社区  ›  kaka1234

'AmazonDynamoDBClient。PutItem(PutItemRequest)“”由于其保护级别而无法访问'

  •  2
  • kaka1234  · 技术社区  · 7 年前

    dynamodb的新用户,并尝试将其与my集成。净核心。

    我在以下方面使用了该示例: 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.
    

    这里缺少什么?

    谢谢

    1 回复  |  直到 7 年前
        1
  •  1
  •   kaka1234    7 年前

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

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

    虽然这个链接是针对移动平台的,但这正是我发现并起作用的。