Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve top n records from Azure Table Storage with .NET Core

Is it possible to retrieve the Top n records from the Azure Table Storage using C#? I'm using .NET Core.

It would be great if I can get some references as well.

Please note that all my entities are stored using the Log Tail Pattern https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-design-guide#log-tail-pattern

Thanks, Praveen

like image 376
Prawin Avatar asked Jun 04 '18 14:06

Prawin


People also ask

How do you retrieve data from Table storage in Azure?

Enter an Account Name, Account Key, and Table Name on the Azure Table tab of the New Session dialog. Select either HTTP or HTTPS as the connection Protocol. Ensure that the Analysis Grid viewer is selected in the Start With drop-down list. Start retrieving data by clicking the Start button in the New Session dialog.

What is RowKey in Azure Table Storage?

The row key is a unique identifier for an entity within a given partition. Together the PartitionKey and RowKey uniquely identify every entity within a table. The row key is a string value that may be up to 1 KiB in size. You must include the RowKey property in every insert, update, and delete operation.


Video Answer


1 Answers

You can use Take() method when creating your TableQuery:

TableQuery<T> query = new TableQuery<T>().Take(takeCount);

Or set the property TakeCount to specify it:

TableQuery<T> query = new TableQuery<T>();
query.TakeCount = takeCount;
like image 138
Zhaoxing Lu Avatar answered Nov 14 '22 23:11

Zhaoxing Lu