c# - 如何使用 Azure.Data.Tables 列出表(按前缀)?

标签 c# azure azure-table-storage

我使用Azure.Data.Tables。 我发现我很可能应该使用 Azure.Data.Tables.TableServiceClient.QueryAsync(...) ( docs ) 来列出表,但是我找不到有关过滤器语法的任何文档字符串。我可以避免指定过滤字符串并在客户端进行过滤,但这不是正确的方法。

文档中只有一个示例:

filter
String
Returns only tables that satisfy the specified filter. For example, the following would filter tables with a Name of 'foo': "TableName eq 'foo'".

但是过滤字符串的完整文档在哪里,更具体地说,如何按前缀列出表?在 Microsoft.Azure.Cosmos.Table.CloudTableClient.ListTables 中,似乎可以轻松完成( docs ),但 microsoft recommends移动到Azure.Data.Tables

最佳答案

从 Azure.Data.Tables SDK 12.4.0 版本开始,这是不可能的。

但是我确实在 GitHub 上的 SDK 存储库上发现了一个问题:https://github.com/Azure/azure-sdk-for-net/issues/24414这向我指出了一个解决方法:https://github.com/NuGet/Insights/blob/6d23681b17d7c131f7f2ab25b111fc4bcb421ba6/src/ExplorePackages.Logic/Storage/TableExtensions.cs .

来自第二个链接:

public static AsyncPageable<TableItem> GetTablesAsync(this TableServiceClient client, string prefix)
{
    var prefixQuery = TableClient.CreateQueryFilter<TableItem>(
        x => x.TableName.CompareTo(prefix) >= 0
          && x.TableName.CompareTo(prefix + char.MaxValue) <= 0);

    return client.GetTablesAsync(filter: prefixQuery);
}

关于c# - 如何使用 Azure.Data.Tables 列出表(按前缀)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71381694/

相关文章:

c# - Dispatcher' 不包含 'InvokeAsync' 的定义并且没有扩展方法 'InvokeAsync'

node.js - Node 项目的 Azure git 部署失败

java - jClouds 是否支持 MS Azure 表存储服务

.net - Azure 存储表、有关查询和查询处理的问题

c# - Glimpse 不工作

c# - 在指针参数上使用 ref 和 out 关键字

c# - 在不访问 MouseEventArgs 的情况下获取鼠标状态?

node.js - Azure 网站上的 iisnode 和 cors

visual-studio - 将 .NET Core 2.0 Web 应用程序发布到 Azure 应用服务时出错

Azure表存储: Is there a way to check if the property does exist?