Struct PartitionKey<TEntity>
- Namespace
- DynaSharp
- Assembly
- DynaSharp.dll
A partition key that remembers its entity, which is what the generated Order.Keys.Pk.Of(userId) and Order.Keys.ByStatusPk.Of(status) return.
orders.Query(Order.Keys.Pk.Of(id)) checks the key against the table, so orders.Query(Customer.Keys.Pk.Of(id)) is a compile error. A table without a schema takes the
key of any entity, because it reads several: shop.Query(Order.Keys.Pk.Of(id)).Of<Customer, Order>().
public readonly struct PartitionKey<TEntity> where TEntity : IDynamoDbEntity<TEntity>
Type Parameters
TEntityThe entity the key belongs to.
- Inherited Members
Remarks
No conversion. It does not convert to AttributeValue on its own: a table of an entity takes no key given as its stored values, which would skip the template, so a key
of another entity would have a way through. Value is the explicit way out, and a table without a schema, client.Table(name, partitionKey, sortKey), takes the values.
The entity is all the type knows, so the partition key of a table and the one of its index have one type: the compiler does not tell them apart. The key remembers the attribute it was built
for, so Query does, and throws ArgumentException naming the key builder to use instead of asking DynamoDB for a partition that cannot exist. Two keys of one attribute are one
key to it, which is what lets several entities overload an index. The formatted string exists from the moment the key is made, so this costs what Format costs.
A key holds an AttributeValue, a struct, because a plain key can be a number or binary, which a string would send with the wrong type. A key of a template is a string in that struct at no further cost, and a plain key of another type pays for its text once.
Properties
Value
Gets the key as text: the formatted string, the digits of a number, the base64 of binary. On the default value it is empty, which a query rejects as an empty key.
public string Value { get; }
Property Value
Methods
ToString()
Returns the formatted key.
public override string ToString()