Dynamo DB
This article will show you how to create a WinForms application and access data stored in a DynamoDB table. It shows how you can connect to the AWS DynamoDB service from a blank WinForms project as well.
Please note that you can use the local version of DynamoDB to setup and test your application. This article shows a real example.
Step 1: Create a WinForms project.
First create the WinForms project, to do that create a blank Telerik UI for WinForms project and add a RadGridView and two buttons to it. The application design should look like this:
Step 2: Install the NuGet package
In Visual Studio open the NuGet package manager and install the DynamoDB module:
Another option is to to type the following command in the NuGet Package Manager Console: PM> Install-Package AWSSDK.DynamoDBv2
In addition you need to add the following to your App.config file:
If you do not have a AWS account in Visual Studio please check the Getting Started article.
Step 3: Create the AWS manager class
Add a class called AWS_Manager to the example. You will use this class to add all functionality for managing the DynamoDB database. For now you can create the method that crates the table:
Now when the table is ready you can add some data, add the following method to the AWS_Manager class:
If you run the code at this point you will be able to see the data in your AWS console:
Step 4: Get the Data from DynamoDb
Now you are ready to populate the grid with the data. Although you can directly populate the grid from the data I believe that is better to have a local business object to store the data.
First you need to get the data. The following method will return a List<Document>
, each document represents an entry from the database.
We can use the above method to iterate the documents and get the data. Here is the code along with the business object.
The grid is now populated.
Step: 5 Save the Changes
The final steps is to save the changes. Upon a button click we will iterate all rows and update the items in the database. We will need a function that updates an item in the manager class. Here is the code.