コード例 #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //エンティティをテーブルに1件追加
            var l = System.Environment.TickCount;

            var constr = new Properties.Settings().StorageConnectionString;
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(constr);

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("people");

            // Create a new customer entity.
            CustomerEntity customer1 = new CustomerEntity("Harp", "Walter" + _n);
            customer1.Email = "*****@*****.**";
            customer1.PhoneNumber = "425-555-0101";

            _n++;

            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(customer1);

            // Execute the insert operation.
            table.Execute(insertOperation);

            Debug.WriteLine($"処理時間={(System.Environment.TickCount - l)}ms");
        }
コード例 #2
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            //エンティティのバッチを挿入する

            var constr = new Properties.Settings().StorageConnectionString;
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(constr);

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("people");

            // Create the batch operation.
            TableBatchOperation batchOperation = new TableBatchOperation();

            var l = System.Environment.TickCount;

            for(var c = 0; c < 100; c++)
            {
                // Create a customer entity and add it to the table.
                CustomerEntity customer = new CustomerEntity("kiyotaka", "abe" + c);
                customer.Email = "*****@*****.**" + c;
                customer.PhoneNumber = "425-555-0104" + c;

                batchOperation.Insert(customer);
            }

            // Execute the batch operation.
            table.ExecuteBatch(batchOperation);

            //2015/11/27
            //処理時間=1265ms

            //2016/12/17土
            //処理時間 = 313ms
            Debug.WriteLine($"処理時間={(System.Environment.TickCount - l)}ms");
        }