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

Getting multiple items using the AWS SDK for .Net


Let's understand how to get multiple items from the DynamoDB table using the AWS SDK for .Net.

Getting ready

To perform this operation, you can use the IDE of your choice.

How to do it…

Let's try to understand how to get multiple stored items from the DynamoDB table using .Net:

  1. Create an instance of the AmazonDynamoDBClient class:

    AmazonDynamoDBClient client = new AmazonDynamoDBClient();
    string tableName = "productTable";
  2. Create BatchGetItemRequest specifying the items to be fetched. You can also fetch multiple items together from various tables:

    var request = new BatchGetItemRequest
    {
      RequestItems = new Dictionary<string, KeysAndAttributes>()
      {
        {
          tableName,
          new KeysAndAttributes
          {
            Keys = new List<Dictionary<string, AttributeValue>>()
            {
              new Dictionary<string, AttributeValue>()
              {
                { "id", new AttributeValue { N = 10 } },
                { "type", new AttributeValue...