Код: Выделить всё
var request = new GetItemRequest()
{
TableName = AccountsTable,
Key = new Dictionary()
{
{ "CustomerName", new AttributeValue() { S = "John" } },
{ "CustomerType", new AttributeValue() { S = CustomerType.ToString() } }, // An enum passed to the method
}
};
var response = await dynamoDbClient.GetItemAsync(request, ct).ConfigureAwait(false);
foreach (var kvp in response.Item)
{
Console.WriteLine(JsonSerializer.Serialize(kvp)); // Item successfully selected and logged, and I can see the Item values in cloudWatch.
}
if (response.Item.Count == 0) return null;
var itemAsDocument = Document.FromAttributeMap(response.Item); // exception raised.
но как только он достигает линия:
Код: Выделить всё
var itemAsDocument = Document.FromAttributeMap(response.Item);
Код: Выделить всё
fail System.InvalidCastException: Specified cast is not valid.
at Amazon.DynamoDBv2.DocumentModel.DynamoDBEntry.AsString()
Подробнее здесь: https://stackoverflow.com/questions/792 ... -not-valid
Мобильная версия