예제 #1
0
        private async Task PullData(Dictionary <string, AttributeValue> currentKey)
        {
            do
            {
                var request = new QueryRequest
                {
                    TableName                 = PostsTableName,
                    ExclusiveStartKey         = currentKey,
                    KeyConditionExpression    = "id = :v_post",
                    ExpressionAttributeValues = { { ":v_post", new AttributeValue {
                                                        S = "post"
                                                    } } }
                };
                var result = await dynamoDbRepository.QueryAsync(request);

                posts      = posts.Concat(result.Items.Select(i => new Post(i))).OrderByDescending(p => p.UnixTimestamp).ToArray();
                currentKey = result.LastEvaluatedKey;
            } while (currentKey.Any());
        }
예제 #2
0
        private async void LoadAlbums()
        {
            try
            {
                Console.WriteLine("Starting to load albums");
                var currentKey = new Dictionary <string, AttributeValue>();
                var albumsList = new List <Album>();
                do
                {
                    var request = new QueryRequest
                    {
                        TableName                 = AlbumsTableName,
                        ExclusiveStartKey         = currentKey,
                        KeyConditionExpression    = "id = :v_album",
                        ExpressionAttributeValues = { { ":v_album", new AttributeValue {
                                                            S = "album"
                                                        } } }
                    };
                    var result = await dynamoDbRepository.QueryAsync(request);

                    albumsList.AddRange(result.Items.Select(i => new Album(i)));
                    currentKey = result.LastEvaluatedKey;
                } while (currentKey.Any());

                Console.WriteLine("Done loading {0} albums", albumsList.Count);
                lock (this)
                {
                    albums   = Enumerable.Reverse(albumsList).ToArray();
                    updating = false;
                }
            }
            catch (Exception x)
            {
                Console.WriteLine(x);
            }
        }