Class Document
- Namespace
- Amazon.DynamoDBv2.DocumentModel
- Assembly
- AWSSDK.DynamoDBv2.dll
A collection of attribute key-value pairs that defines an item in DynamoDB.
public class Document : DynamoDBEntry, ICloneable, IDictionary<string, DynamoDBEntry>, ICollection<KeyValuePair<string, DynamoDBEntry>>, IEnumerable<KeyValuePair<string, DynamoDBEntry>>, IEnumerable- Inheritance
- 
      
      
      Document
- Implements
- Inherited Members
Constructors
Document()
Constructs an empty Document.
public Document()Document(Dictionary<string, DynamoDBEntry>)
Constructs a Document with the passed-in values as its attribute values.
public Document(Dictionary<string, DynamoDBEntry> values)Parameters
- valuesDictionary<string, DynamoDBEntry>
Properties
Count
Gets the count of attributes.
public int Count { get; }Property Value
IsReadOnly
Returns true if the document is read only.
public bool IsReadOnly { get; }Property Value
this[string]
Attribute accessor, allows getting or setting of an individual attribute.
public DynamoDBEntry this[string key] { get; set; }Parameters
- keystring
- Name of the attribute. 
Property Value
- DynamoDBEntry
- Current value of the attribute. 
Keys
This list of attribute keys for the document.
public ICollection<string> Keys { get; }Property Value
Values
Get a list of all the values in the Document.
public ICollection<DynamoDBEntry> Values { get; }Property Value
Methods
Add(KeyValuePair<string, DynamoDBEntry>)
Add attributes to Document.
public void Add(KeyValuePair<string, DynamoDBEntry> item)Parameters
- itemKeyValuePair<string, DynamoDBEntry>
Add(string, DynamoDBEntry)
Add value to Doucment.
public void Add(string key, DynamoDBEntry value)Parameters
- keystring
- valueDynamoDBEntry
Clear()
Clear attributes from document.
public void Clear()Clone()
Clones the Document
public override object Clone()Returns
Contains(KeyValuePair<string, DynamoDBEntry>)
Check to see if the attributes are in the Document.
public bool Contains(KeyValuePair<string, DynamoDBEntry> item)Parameters
- itemKeyValuePair<string, DynamoDBEntry>
Returns
Contains(string)
Determines if a specific attribute is set on the Document.
public bool Contains(string attributeName)Parameters
- attributeNamestring
- Attribute name 
Returns
- bool
- Returns true if the specified attribute is found; false otherwise. 
ContainsKey(string)
Check to see if the value is set on the document.
public bool ContainsKey(string key)Parameters
- keystring
Returns
CopyTo(KeyValuePair<string, DynamoDBEntry>[], int)
Copies the attributes to the array.
public void CopyTo(KeyValuePair<string, DynamoDBEntry>[] array, int arrayIndex)Parameters
- arrayKeyValuePair<string, DynamoDBEntry>[]
- arrayIndexint
DecodeBase64Attributes(params string[])
Decodes root-level Base64-encoded strings to their binary representations. Use this method if the Document was constructed from JSON that contains base64-encoded binary values, which result from calling ToJson on a Document with binary data.
Individual strings become binary data. List and sets of Base64-encoded strings become lists and sets of binary data.
public void DecodeBase64Attributes(params string[] attributeNames)Parameters
- attributeNamesstring[]
- Names of root-level attributes to decode. 
Equals(object)
Compare the document to see if it is equal.
public override bool Equals(object obj)Parameters
- objobject
Returns
ForceConversion(DynamoDBEntryConversion)
Returns a new instance of Document where all unconverted .NET types are converted to DynamoDBEntry types using a specific conversion.
public Document ForceConversion(DynamoDBEntryConversion conversion)Parameters
- conversionDynamoDBEntryConversion
Returns
FromAttributeMap(Dictionary<string, AttributeValue>)
Creates a Document from an attribute map.
public static Document FromAttributeMap(Dictionary<string, AttributeValue> data)Parameters
- dataDictionary<string, AttributeValue>
- Map of attribute names to attribute values. 
Returns
- Document
- Document representing the data. 
FromJson(string)
Creates a document from a JSON string. The conversion is as follows: Objects are converted to DynamoDB M types. Arrays are converted to DynamoDB L types. Boolean types are converted to DynamoDB BOOL types. Null values are converted to DynamoDB NULL types. Numerics are converted to DynamoDB N types. Strings are converted to DynamoDB S types.
public static Document FromJson(string json)Parameters
- jsonstring
- JSON string. 
Returns
- Document
- Document representing the JSON data. 
FromJsonArray(string)
Parses JSON text to produce an array of Document.
public static IEnumerable<Document> FromJsonArray(string jsonText)Parameters
- jsonTextstring
Returns
- IEnumerable<Document>
- An IEnumerable<T> of type Document. 
GetAttributeNames()
Returns the names of all the attributes.
public List<string> GetAttributeNames()Returns
GetEnumerator()
Gets the enumerator for the attributes.
public IEnumerator<KeyValuePair<string, DynamoDBEntry>> GetEnumerator()Returns
GetHashCode()
Implements the GetHashCode.
public override int GetHashCode()Returns
IsAttributeChanged(string)
Returns true if the attribute has been changed.
public bool IsAttributeChanged(string attributeName)Parameters
- attributeNamestring
- Name of the attribute. 
Returns
- bool
- True if the attribute has been changed. 
IsDirty()
Returns true if the document contains attributes that have not been saved.
public bool IsDirty()Returns
- bool
- True if the document contains attributes that have not been saved. 
Remove(KeyValuePair<string, DynamoDBEntry>)
Removes the attributes from the document.
public bool Remove(KeyValuePair<string, DynamoDBEntry> item)Parameters
- itemKeyValuePair<string, DynamoDBEntry>
Returns
Remove(string)
Remove the attribute from the Document.
public bool Remove(string key)Parameters
- keystring
Returns
ToAttributeMap()
Creates a map of attribute names mapped to AttributeValue objects. Converts .NET types using the conversion specified by AWSConfigs.DynamoDBConfig.ConversionSchema
public Dictionary<string, AttributeValue> ToAttributeMap()Returns
ToAttributeMap(DynamoDBEntryConversion)
Creates a map of attribute names mapped to AttributeValue objects.
public Dictionary<string, AttributeValue> ToAttributeMap(DynamoDBEntryConversion conversion)Parameters
- conversionDynamoDBEntryConversion
- Conversion to use for converting .NET values to DynamoDB values. 
Returns
ToAttributeMap(DynamoDBEntryConversion, bool)
Creates a map of attribute names mapped to AttributeValue objects.
public Dictionary<string, AttributeValue> ToAttributeMap(DynamoDBEntryConversion conversion, bool isEmptyStringValueEnabled)Parameters
- conversionDynamoDBEntryConversion
- Conversion to use for converting .NET values to DynamoDB values. 
- isEmptyStringValueEnabledbool
- If the property is false, empty string values will be interpreted as null values. 
Returns
ToAttributeUpdateMap(DynamoDBEntryConversion, bool)
Creates a map of attribute names mapped to AttributeValueUpdate objects.
public Dictionary<string, AttributeValueUpdate> ToAttributeUpdateMap(DynamoDBEntryConversion conversion, bool changedAttributesOnly)Parameters
- conversionDynamoDBEntryConversion
- Conversion to use for converting .NET values to DynamoDB values. 
- changedAttributesOnlybool
- If true, only attributes that have been changed will be in the map. 
Returns
ToAttributeUpdateMap(DynamoDBEntryConversion, bool, bool)
Creates a map of attribute names mapped to AttributeValueUpdate objects.
public Dictionary<string, AttributeValueUpdate> ToAttributeUpdateMap(DynamoDBEntryConversion conversion, bool changedAttributesOnly, bool isEmptyStringValueEnabled)Parameters
- conversionDynamoDBEntryConversion
- Conversion to use for converting .NET values to DynamoDB values. 
- changedAttributesOnlybool
- If true, only attributes that have been changed will be in the map. 
- isEmptyStringValueEnabledbool
- If the property is false, empty string values will be interpreted as null values. 
Returns
ToAttributeUpdateMap(bool)
Creates a map of attribute names mapped to AttributeValueUpdate objects.
public Dictionary<string, AttributeValueUpdate> ToAttributeUpdateMap(bool changedAttributesOnly)Parameters
- changedAttributesOnlybool
- If true, only attributes that have been changed will be in the map. 
Returns
ToExpectedAttributeMap()
Creates a map of attribute names mapped to ExpectedAttributeValue objects.
public Dictionary<string, ExpectedAttributeValue> ToExpectedAttributeMap()Returns
ToExpectedAttributeMap(DynamoDBEntryConversion)
Creates a map of attribute names mapped to ExpectedAttributeValue objects.
public Dictionary<string, ExpectedAttributeValue> ToExpectedAttributeMap(DynamoDBEntryConversion conversion)Parameters
- conversionDynamoDBEntryConversion
- Conversion to use for converting .NET values to DynamoDB values. 
Returns
ToExpectedAttributeMap(DynamoDBEntryConversion, bool)
Creates a map of attribute names mapped to ExpectedAttributeValue objects.
public Dictionary<string, ExpectedAttributeValue> ToExpectedAttributeMap(DynamoDBEntryConversion conversion, bool isEmptyStringValueEnabled)Parameters
- conversionDynamoDBEntryConversion
- Conversion to use for converting .NET values to DynamoDB values. 
- isEmptyStringValueEnabledbool
- If the property is false, empty string values will be interpreted as null values. 
Returns
ToJson()
Converts the current Document into a matching JSON string.
DynamoDB types are a superset of JSON types, thus the following DynamoDB cannot be properly represented as JSON data: PrimitiveList (SS, NS, BS types) - these sets will be converted to JSON arrays Binary Primitive (B type) - binary data will be converted to Base64 strings
If the resultant JSON is passed to Document.FromJson, the binary values will be treated as Base64 strings. Invoke Document.DecodeBase64Attributes to decode these strings into binary data.
public string ToJson()Returns
- string
- JSON string corresponding to the current Document. 
ToJsonPretty()
Converts the current Document into a matching pretty JSON string.
DynamoDB types are a superset of JSON types, thus the following DynamoDB cannot be properly represented as JSON data: PrimitiveList (SS, NS, BS types) - these sets will be converted to JSON arrays Binary Primitive (B type) - binary data will be converted to Base64 strings
If the resultant JSON is passed to Document.FromJson, the binary values will be treated as Base64 strings. Invoke Document.DecodeBase64Attributes to decode these strings into binary data.
public string ToJsonPretty()Returns
- string
- JSON string corresponding to the current Document. 
TryGetValue(string, out DynamoDBEntry)
Gets the value associated with the specified attribute value.
public bool TryGetValue(string attributeName, out DynamoDBEntry entry)Parameters
- attributeNamestring
- Attribute name 
- entryDynamoDBEntry
- If the specified attribute value is found, returns the value associated with the attribute; otherwise, null. 
Returns
- bool
- True if attribute is found; false otherwise