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

Putting an item into the DynamoDB table using the AWS SDK for .Net


Let's understand how to put an item into 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 insert an item into DynamoDB table using the AWS SDK for .Net:

  1. Create an instance of the DynamoDB client, and use this to put an item into the table:

    AmazonDynamoDBClient client = new AmazonDynamoDBClient();
    string tableName = "productTable";
  2. Now, create a PutItemRequest with the desired parameters, and invoke the PutItem method:

    var request = new PutItemRequest
    {
       TableName = tableName,
       Item = new Dictionary<string, AttributeValue>()
          {
              { "id", new AttributeValue { N = "20" }},
              { "type", new AttributeValue { S = "book" }},
              { "stock", new AttributeValue { N = "110" }},
              { "price", new AttributeValue { N = "55" }},
              { "title", new AttributeValue { S = "Mastering DynamoDB" }},
             ...