当前位置: 首页>>代码示例>>C#>>正文


C# TableBatchOperation.IndexOf方法代码示例

本文整理汇总了C#中TableBatchOperation.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# TableBatchOperation.IndexOf方法的具体用法?C# TableBatchOperation.IndexOf怎么用?C# TableBatchOperation.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TableBatchOperation的用法示例。


在下文中一共展示了TableBatchOperation.IndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoTableBatchBasicOperationsCheck

        private void DoTableBatchBasicOperationsCheck(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;

            string pk = Guid.NewGuid().ToString();
            TableBatchOperation batch = new TableBatchOperation();

            // Add insert
            DynamicTableEntity ent1 = GenerateRandomEntity(pk);
            TableOperation operation1 = TableOperation.Insert(ent1);
            batch.Add(operation1);

            DynamicTableEntity ent2 = GenerateRandomEntity(pk);
            TableOperation operation2 = TableOperation.Insert(ent2);
            batch.Add(operation2);

            TableOperation[] operationsArray = new TableOperation[2];
            batch.CopyTo(operationsArray, 0);

            Assert.AreEqual(operation1.Entity.RowKey, operationsArray[0].Entity.RowKey);
            Assert.AreEqual(operation1.OperationType, operationsArray[0].OperationType);
            Assert.AreEqual(operation2.Entity.RowKey, operationsArray[1].Entity.RowKey);
            Assert.AreEqual(operation2.OperationType, operationsArray[1].OperationType);

            Assert.AreEqual(0, batch.IndexOf(operation1));
            Assert.AreEqual(1, batch.IndexOf(operation2));

            IEnumerator<TableOperation> enumerator = batch.GetEnumerator();
            int totalCount = 0;
            while (enumerator.MoveNext())
                totalCount++;
            Assert.AreEqual(2, totalCount);

            Assert.IsTrue(batch.Remove(operation2));
            Assert.IsFalse(batch.IsReadOnly);
            TestHelper.ExpectedException<NotSupportedException>(() => batch[0] = operation1,
                    "Setter is not supported for TableBatchOperation");
        }
开发者ID:vinaysh-msft,项目名称:azure-storage-net,代码行数:38,代码来源:TableBatchOperationTest.cs


注:本文中的TableBatchOperation.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。