Retrieving items from the DynamoDB table using the object persistence model in .Net
Now, we will see how to use the object persistence model in .Net to get the data from DynamoDB.
Getting ready
To perform this recipe, you should have set up the project, as described in the earlier recipes, specifically, pom.xml
, dependencies, and the object model.
How to do it…
Create an instance of
AmazonDynamoDBClient
and instantiate theDynamoDBContext
class, which will be the entry point to DynamoDB:AmazonDynamoDBClient client = new AmazonDynamoDBClient(); DynamoDBContext context = new DynamoDBContext(client);
Invoke the load method from the
DynamoDBContext
class, specifying the keys of a DynamoDB item that you wish to retrieve:Product productRetrieved = context.Load<Product>(111, "book");
How it works…
The AWS SDK internally calls the HTTP APIs to perform the operations. The load method retrieves the data from DynamoDB and puts it into the object that we created. To retrieve a specific attribute of the...