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

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


Now, we are going to see how to scan 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, dependencies, and the object model.

How to do it…

  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 scan condition to fetch all the items whose type is book:

    context.Scan<Product>(
    new ScanCondition("type", ScanOperator.EqualTo, "book"));
  3. Now, we can iterate over the products' list to go through the results.

How it works…

The AWS SDK internally calls the HTTP APIs to perform the operations. Here, we are using the equal to condition operator to fetch the results, but as per...