3

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?

2
  • 1
    Please add following line using System.Linq; Commented Jul 11, 2022 at 9:15
  • 1
    @MarkusMeyer Thanks so much! I didn't know until now that the Take method was part of LINQ. Always assumed it was part of Azure's Table Storage API. Commented Jul 11, 2022 at 9:26

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

But that is directly from Azure, what if I were to query using the Azure.Data.Tables package for .NET?
If your goal is to create a Linq Expression which will be translated to the proper $filter, $top, $select equivalents I have posted an example over here: stackoverflow.com/a/73772499/1209734
0

Please add linq to the usings:

using System.Linq;

MS Docs: Enumerable.Take Method

Namespace: System.Linq

1 Comment

This is a VERY BAD IDEA. Filtering should be done on the server side not on the client side! Proper example in the docs: learn.microsoft.com/en-us/dotnet/api/overview/azure/…
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.