Namespace DynaSharp.Mapping
Classes
- ComputedFromAttribute
Names the stored properties a computed property is derived from, so that it can feed a key template of an index. A getter is code the generator cannot read, so this is the promise it goes by: the getter reads what is named here and nothing else that an update can change.
- DiscriminatorAttribute
Sets the discriminator of an entity: the value stored in each of its items, in an attribute named
_type, that tells which entity an item is, so that several entities can share a table and a typed read gets its own items. It is required on every entity, as[Discriminator("ORDER")].
- DynamoDbAttributeAttribute
Sets the DynamoDB attribute name of a property. Without it the name is the C# property name, as Naming converts it, and unchanged by default.
- DynamoDbConstructorAttribute
Selects the constructor that reads use, when a type has several. Without it the parameterless constructor is used, of any accessibility, and otherwise the single constructor. Parameters bind to properties by name, ignoring case.
- DynamoDbConverterAttribute
Selects the converter of a property, or of a type wherever it is used, including inside collections. A converter on a property wins over one on the property's type, and both win over DynamoDbDefaultConverterAttribute and the built-in converters.
- DynamoDbDefaultConverterAttribute
Selects the converter of a type for every mapped type of an assembly, where a DynamoDbConverterAttribute would have to go on every property:
[assembly: DynamoDbDefaultConverter(typeof(DateTimeOffset), typeof(StoredTimestampConverter))]. It can be repeated, once per type.
- DynamoDbDefaultsAttribute
Says once what a project would otherwise repeat on every mapped type:
[assembly: DynamoDbDefaults(Naming = AttributeNaming.CamelCase, DiscriminatorOptOut = true, OmitEmpty = true)]. It holds for the entities and documents that the assembly declares, nested ones too, and it does not reach a type of another assembly, which has the defaults it was built with.
- DynamoDbDocumentAttribute
Maps a type to a DynamoDB map, for a type nested in an entity such as an address. A document has no keys and no discriminator. The type must be
partial, as must its containing types.
- DynamoDbEntityAttribute
Maps a type to a DynamoDB item. The source generator implements the mapping, so the type must be
partial, as must its containing types, and it needs a partition key and a DiscriminatorAttribute.
- DynamoDbEnumAttribute
Says how the converter that the source generator writes for an enum reads a stored name.
[DynamoDbEnum(UnknownName = UnknownEnumName.CountsAsMissing)]makes a name the enum does not have, such as one that a newer version of a service wrote during a rollout, read as if the attribute were not in the item, where it would throw otherwise.
- DynamoDbIgnoreAttribute
Leaves a property out of the mapping: it is neither written nor read, and a key template cannot use it. To store a value only inside a key, use KeyOnlyAttribute.
- GlobalIndexKeyAttribute
Declares the keys of a global secondary index. The default attribute names come from the lowercase index name, so index
GSI1usesgsi1pkandgsi1sk. Index keys are computed on every full write.
- KeyOnlyAttribute
Stores a property only inside a key and restores it by parsing that key, which saves the bytes of a separate attribute. No attribute holds it, so it has no handle in
Attrs: a condition, a filter, an update andSelectcannot name it.
- LocalIndexKeyAttribute
Declares the sort key of a local secondary index. A local index shares the partition key of the table, so there is nothing to declare for it, and it requires a table with a sort key. The default attribute name comes from the lowercase index name, so index
LSI1useslsi1sk.
- OmitEmptyAttribute
Treats an empty string or an empty collection like null, so that an item does not fill up with attributes that say nothing. It goes on a string, list, set, dictionary or array property, nullable or not, that feeds no key, or on an entity or document type, where it covers those properties of that type that feed no key.
[OmitEmpty(false)]takes it back for a property or a type, where a type or OmitEmpty asked for it.
- PartitionKeyAttribute
Declares the partition key of an entity. On the type it takes a key template such as
USER#{UserId}, stored in an attribute namedpk. On a property it takes no template and declares a plain key: the property's own attribute is the key.
- SortKeyAttribute
Declares the sort key of an entity. On the type it takes a key template such as
ORDER#{CreatedAt}#{OrderId}, stored in an attribute namedsk. On a property it takes no template and declares a plain key: the property's own attribute is the key.
- TimeToLiveAttribute
Marks the property whose attribute is the time to live of the table: DynamoDB deletes an item some time after the instant it holds.
CreateTable()of the entity turns time to live on for it, as.TimeToLive(handle)on the chain does, and so doesFakeDynamoDb.CreateTable<T>ofDynaSharp.Testing.
- VersionAttribute
Marks the property that holds the version of an item, for optimistic locking: a new item has version 0, each write stores the version plus 1, and a write of a stale copy fails with ConditionalCheckFailedException. It goes on one integer property of an entity that is not nullable, has no custom converter and is part of no key.
Interfaces
- IDynamoDbDiscriminated<TSelf>
An entity whose items name their type in a discriminator attribute, which is what a mixed read dispatches on, so only such a type fits
shop.Query(pk).Of<Customer, Order>(). The source generator adds this interface to a type with[Discriminator("ORDER")]and leaves it off a type that opted out, which makes a mixed read of that type a compile error.
- 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
TSelfdecides only how an item is written and read.
- IDynamoDbEntity<TSelf>
A document with a primary key, which is what can stand on its own in a table. A nested document such as an address has no key, so it implements IDynamoDbDocument<TSelf> only, and Of<TOther>() and Table<T>(string) do not take it.
- IKey<TEntity>
A primary key of
TEntity.customers.Get(Customer.Keys.Of("alice"))infers the key type from the argument and checks it against the table, so a key of another entity is a compile error.
Enums
- AttributeNaming
How the name of a stored attribute derives from the name of a property, set by Naming.
- UnknownEnumName
What a read of an enum does with a stored name that the enum does not have, which UnknownName says.
- VersionMissing
What an item without a version attribute means to an entity with a VersionAttribute, which Missing says.