CodeName
CodeName

Reputation: 395

Simplest and efficient way to check if a AzureTable has any data?

I would need a way to know the most efficient way to see if a table in azure storage has any data

Exemple

cloudTable.ExecuteQuery("what do i do");

Thanks for the suggestions! I finally did something like this:

var query = new TableQuery<T>()
            {
                TakeCount = 1,
                SelectColumns = new List<string>()
                {
                    "PartitionKey"
                }
            };
var table = await this.GetTableAsync();
var segment = await table.ExecuteQuerySegmentedAsync(query, null);

return segment.Results.Any();

Upvotes: 0

Views: 845

Answers (1)

Igor
Igor

Reputation: 62213

You could do this which limits your query to 1 record if there is data.

// select value = take smallest data field to avoid returning everything for a record
var query = new TableQuery().Select(new List<string>(){"smallcolumn"}).Take(1);

Upvotes: 2

Related Questions