| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
The following table lists the attributes the object persistence model offers so you can map your classes and properties to Amazon DynamoDB tables and attributes.
Note
In the following table, only DynamoDBTable and
DynamoDBHashKey are required tags.
| Declarative Tag (attribute) | Description |
|---|---|
DynamoDBHashKey |
Maps a class property to the hash attribute of the table's primary key. The primary key attributes cannot be a collection type. The following C# code examples maps the [DynamoDBTable("ProductCatalog")]
public class Book {
[DynamoDBHashKey]
public int Id { get; set; }
// Additional properties go here.
}
|
|
|
Indicates |
DynamoDBProperty |
Maps a class property to a table attribute. If the class
property maps to the same name table attribute, then you don't
need to specify this attribute. However, if the names are not
the same, you can use this tag to provide the mapping. In the
following C# statement the [DynamoDBProperty("Authors")]
public List<string> BookAuthors { get; set; }
|
DynamoDBRangeKey |
Maps a class property to the range attribute of the table's primary key. If the table's primary key is made of both the hash and range attributes, you must specify both the DynamoDBHashKey and DynamoDBRangeKey attributes in your class mapping. For example, the sample table Reply has a primary key made of the Id hash attribute and Replenishment range attribute. The following C# code example maps the Reply class to the Reply table. The class definition also indicates that two of its properties map to the primary key. For more information about sample tables, see Example Tables and Data in Amazon DynamoDB. [DynamoDBTable("Reply")]
public class Reply {
[DynamoDBHashKey]
public int ThreadId { get; set; }
[DynamoDBRangeKey]
public string Replenishment { get; set; }
// Additional properties go here.
}
|
|
|
Identifies the target table in Amazon DynamoDB to which the class maps.
For example, the following C# code example maps the
[DynamoDBTable("People")]
public class Developer { ...}
This attribute can be inherited or overridden.
You can add the optional parameter,
[DynamoDBTable("People", LowerCamelCaseProperties=true)]
public class Developer {
string DeveloperName;
...}
When saving instances of the |
DynamoDBVersion | Identifies a class property for storing the item version number. To more information about versioning, see Optimistic Locking Using Version Number with Amazon DynamoDB Using the AWS SDK for .NET Object Persistence Model. |