C# azure table 查询返回 501 未实现

C# azure table query returning 501 not implemented

我正在使用 Azure Table 存储并有一个 table 我正在尝试查询行键以我感兴趣的过滤值结尾的位置。这是我的代码:

var query = table.CreateQuery<DynamicTableEntity>().Where(o => o.PartitionKey == somePartitionKey && o.RowKey.EndsWith(string.Format("_{0}", aclId))).AsTableQuery();

然后我执行 ExecuteQuerySegmentedAsync 但由于某种原因抛出以下异常:

A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in mscorlib.dll

Additional information: The remote server returned an error: (501) Not Implemented.

知道这是为什么吗?我的 code/query 有问题导致它失败吗?无论如何,我真的需要一种有效的方法来检索行键以某个值结尾的分区中的所有记录。

您收到此错误的原因是您正在尝试执行不受支持的操作。截至今天,Azure Table 服务不支持 EndsWith 查询运算符。有关受支持的 LINQ 运算符的列表,请参阅此 link:https://msdn.microsoft.com/en-us/library/azure/dd135725.aspx.

在您的方案中,您需要先在客户端下载实体,然后对这些实体应用 EndsWith 运算符。

另请记住,Blob 存储无法访问 table 服务,只能访问通用服务。所以如果你 运行 进入这个并且你知道你已经设置了一个 blob 存储资源那么它就不会工作。