コード例 #1
0
ファイル: InsertBatch.cs プロジェクト: takekazuomi/WAAC201202
        async Task<CommandResult> DoInsert(CloudTable table, long n, Func<long, EntityNk[]> entityFactory)
        {
            
            var batchOperation = new TableBatchOperation();

            foreach (var e in entityFactory(n))
            {
                batchOperation.Insert(e);
            }

            var cresult = new CommandResult { Start = DateTime.UtcNow.Ticks };
            var cbt = 0L;
            var context = GetOperationContext((t) => cbt = t);
            try
            {
                var results = await table.ExecuteBatchAsync(batchOperation, operationContext: context);
                cresult.Elapsed = cbt;
            }
            catch (Exception ex)
            {
                cresult.Elapsed = -1;
                Console.Error.WriteLine("Error DoInsert {0} {1}", n, ex.ToString());
            }
            return cresult;
        }
コード例 #2
0
ファイル: Insert.cs プロジェクト: takekazuomi/WAAC201202
        async Task<CommandResult> DoInsert(CloudTable table, long n, Func<long, EntityNk> entityFactory)
        {
            var e = entityFactory(n);

#if INSERT_OR_REPLACE
            var tableOperation = TableOperation.InsertOrReplace(e);
#else
            var tableOperation = TableOperation.Insert(e);
#endif
            var cresult = new CommandResult { Start = DateTime.UtcNow.Ticks };
            var cbt = 0L;
            var context = GetOperationContext((t) => cbt = t);
            try
            {
                var result = await table.ExecuteAsync(tableOperation, operationContext: context);
                cresult.Elapsed = cbt;
            }
            catch (Exception ex)
            {
                cresult.Elapsed = -1;
                Console.Error.WriteLine("Error DoInsert {0} {1}", n, ex.ToString());
            }
            return cresult;
        }