Interface IDynamoDbDocument<TSelf>
A type that knows how to write itself as DynamoDB attributes and read itself back: a generated entity, a generated nested document,
or Item. It is what makes one Table<T> serve all of them, because TSelf decides
only how an item is written and read.
public interface IDynamoDbDocument<TSelf> where TSelf : IDynamoDbDocument<TSelf>
Type Parameters
TSelfThe implementing type.
Remarks
Implement it with explicit interface members, so nothing lands on the public surface of the type. The source generator does that for
[DynamoDbEntity] and [DynamoDbDocument] types; write it by hand for a type the generator cannot see.
The methods work without the surrounding braces, so one implementation serves a top-level item, an element of an array of items and a nested map.
Methods
ReadAttributes(ref DynamoDbReader)
Reads the attributes after the opening brace, up to and including the closing one.
public static abstract TSelf ReadAttributes(ref DynamoDbReader reader)
Parameters
readerDynamoDbReaderThe reader, positioned after the opening brace.
Returns
- TSelf
The value.
Exceptions
- DynamoDbMappingException
An attribute is missing or cannot be converted, or the item is of another type.
WriteAttributes(DynamoDbWriter, TSelf)
Writes the attribute names and values, without the surrounding braces.
public static abstract void WriteAttributes(DynamoDbWriter writer, TSelf entity)
Parameters
writerDynamoDbWriterThe writer, positioned inside an item or a map.
entityTSelfThe value to write.
WriteNextVersion(DynamoDbWriter, TSelf)
Writes the attributes as a put of a VersionAttribute entity stores them, with the version after the one the value holds. The value is left as it is, and WriteAttributes(DynamoDbWriter, TSelf) writes the version as it stands, so that a plain copy stays one. The generator implements this for a type with a version; a type written by hand that names a version attribute in its DynaSharp.Mapping.DynamoDbEntityInfo implements it too.
public static long WriteNextVersion(DynamoDbWriter writer, TSelf entity)
Parameters
writerDynamoDbWriterThe writer, positioned inside an item.
entityTSelfThe value to write.
Returns
- long
The version the value holds, which is the one the put expects to find.
Exceptions
- NotSupportedException
The type does not implement this.
- OverflowException
The next version does not fit the property.