我使用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/