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

Saving items into the DynamoDB table using the object persistence model in .Net


In the earlier recipes, we discussed how to use the object persistence model using Java; now, we will see how to use 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…

Let's see how to use the object persistence model in .Net:

  1. Here, we will first create the data model and map the attributes to the attributes in a DynamoDB table. The .Net SDK provides built-in support for the object persistence model, so you don't need to do anything else. Annotations can be used to perform the mapping of data, as shown in the following code:

    [DynamoDBTable("product")]
        public class Product
        {
            [DynamoDBHashKey]   // Hash key.
            public int id { get; set; }
            [DynamoDBRangeKey]   // Range key.
            public string type { get; set; }
          ...