private static async Task <Dictionary <string, Dictionary <string, DynamicTableEntity> > > LoadDataToCache(
            this TableEntitySdk table, Action <int> loadedCallback)
        {
            var buffer = new Dictionary <string, Dictionary <string, DynamicTableEntity> >();

            var loaded = 0;

            await table.GetEntitiesByChunkAsync(chunk =>
            {
                foreach (var entity in chunk)
                {
                    if (!buffer.ContainsKey(entity.PartitionKey))
                    {
                        buffer.Add(entity.PartitionKey, new Dictionary <string, DynamicTableEntity>());
                    }
                    buffer[entity.PartitionKey].Add(entity.RowKey, entity);

                    Console.CursorLeft = 0;
                }

                loaded += chunk.Length;

                loadedCallback(loaded);

                return(Task.FromResult(0));
            });

            return(buffer);
        }
        private async Task ReadWriteTaskAsync()
        {
            var written = 0;
            await _srcTable.GetEntitiesByChunkAsync(async chunk =>
            {
                if (!_skipBuffer)
                {
                    EntitiesBuffer.Add(chunk);
                }

                await _destTable.InsertAsync(chunk);
                written += chunk.Length;
                Console.WriteLine("Written entities : " + written);
            });
        }
Ejemplo n.º 3
0
        public static async Task MatchEntitiesAsync(this TableEntitiesBuffer buffer, TableEntitySdk tableEntitySdk)
        {
            var matched = 0;

            await tableEntitySdk.GetEntitiesByChunkAsync(chunk =>
            {
                return(Task.Run(() =>
                {
                    foreach (var entity in chunk)
                    {
                        if (!buffer.HasEntity(entity))
                        {
                            throw new Exception("Partition " + entity.ToJson() +
                                                " is not found at the dest tablestorage");
                        }
                    }

                    matched += chunk.Length;

                    Console.WriteLine("Matched entities: " + matched);
                }));
            });
        }