While using AWS DynamoDB "Object Persistence Model" in C#, ran into an interesting issue; parsing results of a Scan operation. In the code below, my entries in Datastore.userIndicators (which is a Dictionary with Lists of objects, indexed by usernames) are always empty lists.
var allIndicators = context.Scan<Indicator>();
Datastore.globalIndicators = allIndicators.Where(i => i.UserName == "*").ToList();
var userDefinedIndicators = allIndicators.Where(i => i.UserName != "*");
foreach (var username in userDefinedIndicators.Select(i => i.UserName).Distinct())
{
Datastore.userIndicators[username] = userDefinedIndicators.Where(i => i.DynamoDbRangeKey.StartsWith(username)).ToList();
}
So, for example, if I have entries in my table that include an attribute "UserName" with value "userA", when running this code the Dictionary "Datastore.userIndicators" will end up with an entry for key "userA" but the corresponding value will be an empty list.