Book Image

DynamoDB Cookbook

By : Tanmay Deshpande
Book Image

DynamoDB Cookbook

By: Tanmay Deshpande

Overview of this book

Table of Contents (18 chapters)
DynamoDB Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Querying items from the DynamoDB table using the object persistence model in .Net


Now, we are going to see how to query items from the table using the object persistence model in .Net

Getting ready

To perform this recipe, you should have set up the project, as described in the earlier recipes, specifically pom.xml and setting up dependencies and the object model.

How to do it…

Let's see how to query items from the table using the object persistence model in .Net:

  1. Create an instance of AmazonDynamoDBClient and instantiate the DynamoDBContext class, which will be the entry point to DynamoDB:

    AmazonDynamoDBClient client = new AmazonDynamoDBClient();
    DynamoDBContext context = new DynamoDBContext(client);
  2. Now, let's write a query that will fetch the items whose ID is 111 and type starts with b:

    IEnumerable<Product> products =
                 context.Query<Product>(111, QueryOperator.BeginsWith, "b");
  3. Now, we can iterate over the products' list to go through the results.

How it works…

The AWS SDK...