예제 #1
0
        public async Task UpdateMultipleEntitiesAsync(IOperation <TEntity> operation)
        {
            var table = await GetTable();

            var entities = table.CreateQuery <TEntity>().Where(operation.Criteria).ToList();

            foreach (var entity in entities)
            {
                operation.Mutation.Invoke(entity);
            }

            var replaces = entities.Where(operation.Validation).Select(entity => TableOperation.Replace(entity));

            var batch = new TableBatchOperation();

            foreach (var replace in replaces)
            {
                batch.Append(replace);
            }

            // TODO: check operation for each entity
            var results = await table.ExecuteBatchAsync(batch);
        }