我通过以下方法公开我的表:
public static class TableCacheService
{
public static IEnumerable<Myentity> Read()
{
var acc = new CloudStorageAccount(
new StorageCredentials("account", "mypass"), false);
var tableClient = acc.CreateCloudTableClient();
var table = tableClient.GetTableReference("Myentity");
return table.ExecuteQuery(new TableQuery<Myentity>());
}
}
这是一个使用示例:
var nodeHasValue = TableCacheService.Read()
.Where(x => note.ToLower().Contains(x.RowKey.ToLower()))
.Any();
但据说x.RowKey
为空!
看起来有 2 个成员都称为 RowKey
。其中之一是 TableEntity
:
如何访问非空的 RowKey?我是否错误地查询了表?
最佳答案
您似乎在 Myentity
类中隐藏了 RowKey
和 PartitionKey
属性。
我猜你的Myentity
类有类似的东西:
public class Myentity: TableEntity
{
public new string RowKey { get; set; }
...
}
注意关键字new。
如果您有此构造,则需要删除此属性。
有关隐藏和覆盖的更多信息,您可以找到 here .
另请查看 ATS(Azure 表存储)的工作示例 here .
关于c# - 如何通过 IEnumerable 使用 TableQuery 进行查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52193134/