EfficientDynamoDb
EfficientDynamoDb copied to clipboard
Single Table Design improvements
Predicate approach
Retrieving multiple entities of a different type in a single query is tricky in C#. Currently, you have to retrieve documents, then create multiple collections and fill them based on some conditions.
One of the ideas to improve this process is to expose ToListAsync<A, B, ...> overloads that accept predicates for each of the output types and returns a tuple.
var (mixedEntities, stringEntities) = await context.Query<KeysOnlyEntity>()
.AsDocuments()
.ToListAsync<MixedEntity, MediumStringFieldsEntity>(x => x["sk"].AsString().StartsWith("mixed#"), x => x["sk"].AsString().StartsWith("string#"));