Prithvidiamond
Prithvidiamond

Reputation: 367

Limiting query results using TableClient.Query from Azure.Data.Tables

In the older API (WindowsAzure.Storage), there was the Take() method for this purpose, but it seems that has been removed in this newer API. I haven't been able to find a way to perform the same function, can someone provide an answer to this?

Upvotes: 3

Views: 1275

Answers (3)

Markus Meyer
Markus Meyer

Reputation: 3937

Please add linq to the usings:

using System.Linq;

MS Docs: Enumerable.Take Method

Namespace: System.Linq

Upvotes: 0

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

The parameter you are looking for is maxPerPage in TableClient.Query.

From the documentation:

maxPerPage Nullable The maximum number of entities that will be returned per page. Note: This value does not limit the total number of results if the result is fully enumerated.

Upvotes: 0

Abhishek Khandave
Abhishek Khandave

Reputation: 3230

You can use $filter, $top or $select to limit query results.

$filter Returns only tables or entities that satisfy the specified filter. Note that no more than 15 discrete comparisons are permitted within a $filter string.

$top Returns only the top n tables or entities from the set.

$select Returns the desired properties of an entity from the set.

To return the top n entities for any query, specify the $top query option. The following example returns the top 10 entities from a table named Customers:

Sample query –

https://myaccount.table.core.windows.net/Customers()?$top=10

Refer - https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#sample-query-expressions

Upvotes: 1

Related Questions