The Data Model api uses .NET classes to model data that will be stored in and retrieved from DynamoDB. For the TODO list application a list is modeled by the TODOList class which contains a collection of TODOListItem for each task in the list.
The DynamoDBContext object is used to save and load .NET objects from DynamoDB. DynamoDBContext takes care of translating the data from the properties on the TODOList and TODOListItem to the service clients AttributeValue objects.
| Property | DynamoDB Type |
|---|---|
| User | S |
| ListId | S |
| Complete | BOOL |
| CreateDate | S |
| UpdateDate | S |
| Items | L<M> |
| -> TODOListItem.Description | S |
| -> TODOListItem.AssignedEmail | S |
| -> TODOListItem.Complete | BOOL |
Note: In this example the DynamoDBContextConfig.Conversion is set to DynamoDBEntryConversion.V2. This should be set for all new applications as it supports the BOOL, L and M DynamoDB types. The original V1 conversion was created before those types existed and switching the default to V2 would be a breaking change to existing users.
To save a TODOList we need to create the TODOList object and then call the SaveAsync method on the context.
To load an object we need to call the LoadAsync method passing in the values for the key.
The QueryAsync returns back an AsyncSearch object. This object can be used to get a page of data over and over again by calling the GetNextSetAsync. Since we want all of the lists for the user we can skip dealing with pagination and call GetRemainingAsync to get all of the lists.
To delete an object we need to call the DeleteAsync method passing in the values for the key.
- Getting Started
- What is a serverless application?
- Common AWS Serverless Services
- What are we going to build in this tutorial?
- TODO List AWS Services Used
- Using DynamoDB to store TODO Lists
- Handling service events with Lambda
- Getting ASP.NET Core ready for Serverless
- Deploying ASP.NET Core as a Serverless Application
- Tear Down
- Final Wrap Up
Continue on to next page: Amazon DynamoDB wrap up