I want to get item from DYnamodb table using C#
Here is my method
public static dynamic Dynamodb() {
string region = "us-east-2";
string tableName = "RetailTestData";
var credentials = new BasicAWSCredentials(Environment.GetEnvironmentVariable("awsAccessKeyId"), Environment.GetEnvironmentVariable("awsSecretAccessKey"));
var client = new AmazonDynamoDBClient(credentials, RegionEndpoint.GetBySystemName(region));
var table = Table.LoadTable(client, tableName);
var item=table.GetItem();
return item;
}
reference taken from
Get Data from a DynamoDB Table in JSON Format
but When I am trying to use the code I am getting an error
at the end I am looking to use item.ToJson()
method as rest of my code uses the json methods
2
Answers
This works for me:
To get an item from Amazon DynamoDB, try using the AWS SDK for .NET V3 (which is the recommended version of the .NET SDK).
You can use the GetItemAsync(). Notice that the call is an async method. If you are not familiar with AWS SDK For .NET V3 – here is the DEV Guide.
What is the AWS SDK for .NET
The C# code is:
This example and other C# examples are located in the Official AWS Code Library.