EfficientDynamoDb icon indicating copy to clipboard operation
EfficientDynamoDb copied to clipboard

Single Table Design improvements

Open lezzi opened this issue 4 years ago • 0 comments

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#"));

lezzi avatar May 28 '21 23:05 lezzi