Table of Contents

Class TableBatchOperation

Namespace
Microsoft.WindowsAzure.Storage.Table
Assembly
Microsoft.WindowsAzure.Storage.dll

Represents a batch operation on a table.

public sealed class TableBatchOperation : IList<TableOperation>, ICollection<TableOperation>, IEnumerable<TableOperation>, IEnumerable
Inheritance
TableBatchOperation
Implements
Inherited Members

Remarks

A batch operation is a collection of table operations which are executed by the Storage Service REST API as a single atomic operation, by invoking an Entity Group Transaction.

A batch operation may contain up to 100 individual table operations, with the requirement that each operation entity must have same partition key. A batch with a retrieve operation cannot contain any other operations. Note that the total payload of a batch operation is limited to 4MB.

Constructors

TableBatchOperation()

Initializes a new instance of the TableBatchOperation class.

public TableBatchOperation()

Properties

Count

Gets the number of operations in this TableBatchOperation.

public int Count { get; }

Property Value

int

The number of operations in the TableBatchOperation.

IsReadOnly

Gets a value indicating whether the TableBatchOperation is read-only.

public bool IsReadOnly { get; }

Property Value

bool

true if the TableBatchOperation is read-only; false, otherwise.

this[int]

Gets or sets the TableOperation item at the specified index.

public TableOperation this[int index] { get; set; }

Parameters

index int

The index at which to get or set the TableOperation item.

Property Value

TableOperation

The TableOperation item at the specified index.

Methods

Add(TableOperation)

public void Add(TableOperation item)

Parameters

item TableOperation

The TableOperation item to add to the TableBatchOperation.

Clear()

Clears all TableOperation objects from the TableBatchOperation.

public void Clear()

Contains(TableOperation)

Returns true if this TableBatchOperation contains the specified element.

public bool Contains(TableOperation item)

Parameters

item TableOperation

The TableOperation item to search for.

Returns

bool

true if the item is contained in the TableBatchOperation; false, otherwise.

CopyTo(TableOperation[], int)

Copies all the elements of the TableBatchOperation to the specified one-dimensional array starting at the specified destination array index.

public void CopyTo(TableOperation[] array, int arrayIndex)

Parameters

array TableOperation[]

A one-dimensional array that serves as the destination for the elements copied from the TableBatchOperation.

arrayIndex int

The index in the destination array at which copying begins.

Delete(ITableEntity)

Adds a TableOperation to the TableBatchOperation that deletes the specified entity from a table.

public void Delete(ITableEntity entity)

Parameters

entity ITableEntity

The entity to be deleted from the table.

GetEnumerator()

Returns an IEnumerator<T> for the TableBatchOperation.

public IEnumerator<TableOperation> GetEnumerator()

Returns

IEnumerator<TableOperation>

An IEnumerator for TableOperation items.

IndexOf(TableOperation)

Returns the zero-based index of the first occurrence of the specified TableOperation item, or -1 if the TableBatchOperation does not contain the item.

public int IndexOf(TableOperation item)

Parameters

item TableOperation

The TableOperation item to search for.

Returns

int

The zero-based index of the first occurrence of item within the TableBatchOperation, if found; otherwise, –1.

Insert(ITableEntity)

Adds a TableOperation to the TableBatchOperation that inserts the specified entity into a table.

public void Insert(ITableEntity entity)

Parameters

entity ITableEntity

The entity to be inserted into the table.

Insert(ITableEntity, bool)

Adds a TableOperation object that inserts the specified entity into the table as part of the batch operation.

public void Insert(ITableEntity entity, bool echoContent)

Parameters

entity ITableEntity

The entity to be inserted into the table.

echoContent bool

true if the message payload should be returned in the response to the insert operation;otherwise, false.

Insert(int, TableOperation)

Inserts a TableOperation into the TableBatchOperation at the specified index.

public void Insert(int index, TableOperation item)

Parameters

index int

The index at which to insert the TableOperation.

item TableOperation

The TableOperation item to insert.

InsertOrMerge(ITableEntity)

Adds a TableOperation to the TableBatchOperation that inserts the specified entity into a table if the entity does not exist; if the entity does exist then its contents are merged with the provided entity.

public void InsertOrMerge(ITableEntity entity)

Parameters

entity ITableEntity

The entity whose contents are being inserted or merged.

InsertOrReplace(ITableEntity)

Adds a TableOperation to the TableBatchOperation that inserts the specified entity into a table if the entity does not exist; if the entity does exist then its contents are replaced with the provided entity.

public void InsertOrReplace(ITableEntity entity)

Parameters

entity ITableEntity

The entity whose contents are being inserted or replaced.

Merge(ITableEntity)

Adds a TableOperation to the TableBatchOperation that merges the contents of the specified entity with the existing entity in a table.

public void Merge(ITableEntity entity)

Parameters

entity ITableEntity

The entity whose contents are being merged.

Remove(TableOperation)

Removes the specified TableOperation item from the TableBatchOperation.

public bool Remove(TableOperation item)

Parameters

item TableOperation

The TableOperation item to remove.

Returns

bool

true if the item was successfully removed; false, otherwise.

RemoveAt(int)

Removes the TableOperation at the specified index from the TableBatchOperation.

public void RemoveAt(int index)

Parameters

index int

The index of the TableOperation to remove from the TableBatchOperation.

Replace(ITableEntity)

Adds a TableOperation to the TableBatchOperation that replaces the contents of the specified entity in a table.

public void Replace(ITableEntity entity)

Parameters

entity ITableEntity

The entity whose contents are being replaced.

Retrieve(string, string)

Adds a TableOperation to the TableBatchOperation that retrieves an entity with the specified partition key and row key.

public void Retrieve(string partitionKey, string rowKey)

Parameters

partitionKey string

A string containing the partition key of the entity to retrieve.

rowKey string

A string containing the row key of the entity to retrieve.

Retrieve<TResult>(string, string, EntityResolver<TResult>, List<string>)

Adds a table operation to retrieve an entity of the specified class type with the specified partition key and row key to the batch operation.

public void Retrieve<TResult>(string partitionKey, string rowKey, EntityResolver<TResult> resolver, List<string> selectedColumns = null)

Parameters

partitionKey string

A string containing the partition key of the entity to retrieve.

rowKey string

A string containing the row key of the entity to retrieve.

resolver EntityResolver<TResult>

The EntityResolver<T> implementation to project the entity to retrieve as a particular type in the result.

selectedColumns List<string>

List of column names for projection.

Type Parameters

TResult

The return type which the specified EntityResolver<T> will resolve the given entity to.

Retrieve<TElement>(string, string, List<string>)

Inserts a TableOperation into the batch that retrieves an entity based on its row key and partition key. The entity will be deserialized into the specified class type which extends ITableEntity.

public void Retrieve<TElement>(string partitionKey, string rowKey, List<string> selectedColumns = null) where TElement : ITableEntity

Parameters

partitionKey string

A string containing the partition key of the entity to retrieve.

rowKey string

A string containing the row key of the entity to retrieve.

selectedColumns List<string>

List of column names for projection.

Type Parameters

TElement

The class of type for the entity to retrieve.