简体   繁体   English

使用 Azure.Data.Tables 中的 TableClient.Query 限制查询结果

[英]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.在较旧的 API (WindowsAzure.Storage) 中,有用于此目的的 Take() 方法,但似乎已在此较新的 API 中删除。 I haven't been able to find a way to perform the same function, can someone provide an answer to this?我一直无法找到执行相同功能的方法,有人可以提供答案吗?

Please add linq to the usings:请将linq添加到使用中:

using System.Linq;

MS Docs: Enumerable.Take Method MS Docs:Enumerable.Take 方法

Namespace: System.Linq命名空间:System.Linq

You can use $filter , $top or $select to limit query results.您可以使用$filter$top$select来限制查询结果。

$filter Returns only tables or entities that satisfy the specified filter. $filter仅返回满足指定过滤器的表或实体。 Note that no more than 15 discrete comparisons are permitted within a $filter string.请注意,在 $filter 字符串中最多允许进行 15 个离散比较。

$top Returns only the top n tables or entities from the set. $top只返回集合中前 n 个表或实体。

$select Returns the desired properties of an entity from the set. $select从集合中返回一个实体的所需属性。

To return the top n entities for any query, specify the $top query option.要返回任何查询的前 n 个实体,请指定 $top 查询选项。 The following example returns the top 10 entities from a table named Customers:以下示例从名为 Customers 的表中返回前 10 个实体:

Sample query –示例查询 –

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

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

The parameter you are looking for is maxPerPage in TableClient.Query .您要查找的参数是maxPerPage中的TableClient.Query

From the documentation:从文档中:

maxPerPage Nullable The maximum number of entities that will be returned per page. maxPerPage Nullable每页将返回的最大实体数。 Note: This value does not limit the total number of results if the result is fully enumerated.注意:如果结果是完全枚举的,这个值不会限制结果的总数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 TableClient.QueryAsync() [Azure.Data.Tables] 中筛选分页查询结果 - How to Filter the query result for pagination in TableClient.QueryAsync() [Azure.Data.Tables] Azure.Data.Tables C# SDK 查询时间戳返回零结果 - Azure.Data.Tables C# SDK query Timestamp returning zero results 如何使用 Azure.Data.Tables 列出表(按前缀)? - How to list tables (by prefix) with Azure.Data.Tables? Azure.Data.Tables 仅查询下一条记录(限制/取 1?) - Azure.Data.Tables querying only next record (limit/take 1?) Azure.Data.Tables 通用基础 class 问题 - Azure.Data.Tables generic base class issue C# Azure - 从 Microsoft.Azure.Cosmos.Table 移动到 Azure.Data.Tables 后找不到指定的资源 - C# Azure - Specified Resource not found after moving from Microsoft.Azure.Cosmos.Table to Azure.Data.Tables Microsoft.Azure.Cosmos.Tables 到 Azure.Data.Tables 迁移:TableEntity Inheritance - Microsoft.Azure.Cosmos.Tables to Azure.Data.Tables migration: TableEntity Inheritance 使用分段执行在Azure TableClient 2.0中分页 - Paging in Azure TableClient 2.0 using Segmented Execution 使用单个linq查询汇总两个表中的数据 - Aggregate data from two tables using single linq query 使用SQL Server 2008从四个表中检索查询数据? - Retrieving query data from four tables using SQL Server 2008?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM