Condividi tramite


IReliableCollection<T>.GetCountAsync(ITransaction) Method

Definition

Gets the number of elements contained in the IReliableCollection<T>.

public System.Threading.Tasks.Task<long> GetCountAsync (Microsoft.ServiceFabric.Data.ITransaction tx);
abstract member GetCountAsync : Microsoft.ServiceFabric.Data.ITransaction -> System.Threading.Tasks.Task<int64>
Public Function GetCountAsync (tx As ITransaction) As Task(Of Long)

Parameters

tx
ITransaction

The transaction to associate this operation with. See examples of transactions here.

Returns

A task that represents the asynchronous operation, indicating the number of elements.

Exceptions

Indicates that the IReliableCollection cannot serve reads at the moment. This exception can be thrown in all ReplicaRoles. One reason it may be thrown in the Primary role is loss of ReadStatus. One reason it may be thrown in the ActiveSecondary role is that Reliable Collection's state is not yet consistent.

The transaction has been internally faulted by the system. Retry the operation on a new transaction

Thrown when a method call is invalid for the object's current state. Example, transaction used is already terminated: committed or aborted by the user. If this exception is thrown, it is highly likely that there is a bug in the service code of the use of transactions.

Thrown when attempting to perform this operation on a IReliableCollection<T> that is not in the Primary role. In some instances, read operations, such as this one, can be performed from secondary replicas depending on the implementation of the IReliableCollection used.

Applies to