本文整理汇总了C#中TableBatchOperation.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# TableBatchOperation.GetEnumerator方法的具体用法?C# TableBatchOperation.GetEnumerator怎么用?C# TableBatchOperation.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableBatchOperation
的用法示例。
在下文中一共展示了TableBatchOperation.GetEnumerator方法的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");
}