CloudTableClient.ListTablesSegmented Method (String, Int32, ResultContinuation)

Storage Client Library NET API

[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]

Returns a result segment containing a collection of table names beginning with the specified prefix. Use this overload when you want to control the maximum number of results returned at a time, and when you want to use a continuation token to determine whether there are more results to return from the service after the current page completes.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)

Usage

Visual Basic
Dim instance As CloudTableClient
Dim prefix As String
Dim maxResults As Integer
Dim continuationToken As ResultContinuation
Dim returnValue As ResultSegment(Of String)

returnValue = instance.ListTablesSegmented(prefix, maxResults, continuationToken)

Syntax

Visual Basic
Public Function ListTablesSegmented ( _
	prefix As String, _
	maxResults As Integer, _
	continuationToken As ResultContinuation _
) As ResultSegment(Of String)
C#
public ResultSegment<string> ListTablesSegmented (
	string prefix,
	int maxResults,
	ResultContinuation continuationToken
)
C++
public:
ResultSegment<String^>^ ListTablesSegmented (
	String^ prefix, 
	int maxResults, 
	ResultContinuation^ continuationToken
)
J#
JScript

Parameters

prefix

Type: System.String

The table name prefix.

maxResults

Type: System.Int32

A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the per-operation limit of 1000. If this value is zero, the maximum possible number of results will be returned, up to 1000.

continuationToken

Type: Microsoft.WindowsAzure.StorageClient.ResultContinuation

A continuation token returned by a previous listing operation.

Return Value

Type: Microsoft.WindowsAzure.StorageClient.ResultSegment

A result segment containing table names.

Example

The following code example lists table names in pages of five. The continuation token will be non-null until the listing is complete.

 Copy Code
public static void ListTablesInPagesWithPrefix(CloudStorageAccount storageAccount, string prefix)
{
    // Create service client for credentialed access to the Table service.
    CloudTableClient tableClient = new CloudTableClient(storageAccount.TableEndpoint.ToString(),
        storageAccount.Credentials);

    //Return a result segment of table names.
    ResultSegment<String> resultSegment = tableClient.ListTablesSegmented(prefix, 5, null);

    //Print table names to the console.
    WriteTableNames(resultSegment);

    //Check HasMoreResults to determine whether the page is complete.
    if (resultSegment.HasMoreResults)
    {
        resultSegment.GetNext();

        //Print table names to the console.
        WriteTableNames(resultSegment);
    }

    //After the page is complete, check the continuation token to determine whether there are more 
    //results on the server.
    while (resultSegment.ContinuationToken != null)
    {
        resultSegment = resultSegment.GetNext();

        //Print table names to the console.
        WriteTableNames(resultSegment);
    }
}
public static void WriteTableNames(ResultSegment<string> resultSegment)
{
    foreach (string tableName in resultSegment.Results)
    {
        Console.WriteLine(tableName);
    }
}

Remarks

The ListTablesSegmented method lists table names in pages. A page is set of results of a specified size; it is represented by the ResultSegment class.

By returning table names in pages, you can control the number of table names returned per operation. This may be useful if, for example, you are displaying a web page with some predefined number of table names on it.

To specify the page size to return, pass in a non-zero value for the maxResults parameter. Passing in zero for the maxResults parameter returns either the maximum number of results available, or the per-operation limit of 1000 results.

If you have specified a page size, you can check the HasMoreResults property to check whether the page is complete. If HasMoreResults is true, the complete page has not been returned for some reason. Call GetNext to return the remaining results in the page.

Note that if you have not specified a page size, HasMoreResults will always be false.Check the value of the ContinuationToken property to determine whether there are more results to return from the service after the page is complete. The continuation token is non-null as long as there are more results to return from the service. If the page is complete, then HasMoreResults will be false, but if the continuation token is non-null, there are additional results to return beyond that page.

Call the GetNext method to return the next segment of results from the service.


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Change History

See Also