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

Creating a table using the AWS SDK for .Net


Now, let's understand how to create a DynamoDB table using the AWS SDK for .Net.

Getting ready

You can use an IDE, such as Visual Studio to code these recipes. You can refer to the AWS documentation on how to set up your workstation at http://aws.amazon.com/sdk-for-net/.

How to do it…

Let's start with creating a table called productTableNet:

  1. Instantiate the CreateTable request specifying AttributeDefinition and KeySchema. We will create the table having both the HASH and RANGE Keys. We will set the provisioned read and write capacity units to be one:

    AmazonDynamoDBClient client = new AmazonDynamoDBClient();
    string tableName = "productTableNet";
    var request=new CreateTableRequest{
      AttributeDefinitions=newList<AttributeDefinition>(){
        newAttributeDefinition{
          AttributeName="id", AttributeType="N"
        },
        newAttributeDefinition{
          AttributeName="type", AttributeType="S"
        }
      },
      KeySchema=newList<KeySchemaElement>{
        newKeySchemaElement...