Export (0) Print
Expand All

CloudTableQuery.Execute Method ()

Updated: April 24, 2013

[This topic is part of the Windows Azure Storage Client Library 1.7, which has been deprecated. The current recommended version is Storage Client Library 3.0.]

Executes the query with the retry policy specified on the CloudTableQuery object.

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


IEnumerable<TElement>^ Execute ()

Return Value

Type: System.Collections.Generic.IEnumerable

The query result.

The following code example creates and executes a query against a table.

public static void ExecuteQuery(CloudStorageAccount storageAccount)
    // Create the service context.
    TableServiceContext context = new TableServiceContext(storageAccount.TableEndpoint.ToString(),

    // Execute the query and write out some data.
    foreach (var entity in context.CreateQuery<ProductEntity>("Products").AsTableServiceQuery<ProductEntity>().Execute())
        Console.WriteLine("Product name: {0} Price: {1}", entity.ProductName, entity.Price);

    // Execute the query with criteria that simulates a LIKE clause.
    foreach (var entity in context.CreateQuery<ProductEntity>("Products")
        .Where(e => (e.ProductName.CompareTo("J") >= 0 && e.ProductName.CompareTo("K") < 0))
        Console.WriteLine("Product name: {0} Price: {1}", entity.ProductName, entity.Price);

// Define a class that represents an entity.
class ProductEntity : TableServiceEntity
    public ProductEntity()

    public string ProductName { get; set; }
    public string Category { get; set; }
    public double Price { get; set; }
    public bool InStock { get; set; }
    public DateTime DateAdded { get; set; }
    public Int32 Quantity { get; set; }

Calling the Execute method retrieves results lazily from the service.

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

Development Platforms

Windows Vista, Windows 7 and Windows Server 2008

Target Platforms

© 2014 Microsoft