Class Index<T>
- Namespace
- DynaSharp
- Assembly
- DynaSharp.dll
A secondary index of a table. An index can be read and not written, and the type says so: it has no Put, Update or Delete, so
what DynamoDB would reject at run time does not compile.
public sealed class Index<T> where T : IDynamoDbDocument<T>
Type Parameters
THow items are read.
- Inheritance
-
Index<T>
- Inherited Members
Remarks
Hold it in a field, as a Table<T>. Instances are immutable and thread-safe.
Queries take a key builder. An index of an entity is queried by the partition key builder of the index, byStatus.Query(Order.Keys.ByStatusPk.Of(status)), and an index of a
table without a schema by the values of its partition key as well, shop.Index("GSI1", "gsi1pk", "gsi1sk").Query("STATUS#open"); they are in EntityTableExtensions and ItemTableExtensions.
Consistency. A global secondary index is always eventually consistent, so a write shows up here a moment after it succeeded; a local secondary index can be read consistently. An index can hold several items with one key, which a page may split at any point, and in a read of several partitions those come as DynamoDB gives them.
What the index projects. A read of an entity filters on its discriminator, and an index gives only what it projects. If the index does not project that attribute, every item fails the filter and the query comes back empty, so such an index is read as Item. DynamoDB refuses a filter on a key of the index, so a query of an index with the discriminator as a key has no filter: the key condition decides, and a read fails with DynamoDbMappingException on an item of another type, which it gets from a partition key of that value, or from an index partition without a condition on a sort key that is the discriminator.
Properties
Name
Gets the name of the index.
public string Name { get; }
Property Value
PartitionKeyName
Gets the attribute name of the partition key of the index.
public string PartitionKeyName { get; }
Property Value
SortKeyName
Gets the attribute name of the sort key of the index, or null if it has none.
public string? SortKeyName { get; }
Property Value
Table
Gets the table of the index.
public Table<T> Table { get; }
Property Value
- Table<T>
Methods
Scan()
Starts a scan of the index, which charges for every item in it. See Index<T> for what is different about reading an index.
public ScanCommand<T> Scan()
Returns
- ScanCommand<T>
The command.