当我使用带有存储表的输入绑定(bind)时,如何访问 RowKey(和 PartitionKey)而不出现错误“隐藏继承的成员 'TableEntity.RowKey”?
我可以愉快地访问基于 PartitionKey 的类别,但是当我尝试通过向我的类添加新属性来扩展获取 RowKey 时,我收到错误... 警告 CS0108: 'Person. RowKey'隐藏继承成员'TableEntity.RowKey'。如果打算隐藏,请使用 new 关键字。
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Table;
public static void Run(string myQueueItem,
IQueryable<Person> tableBinding, TraceWriter log)
{
log.Info($"C# Queue trigger:triggerblocklist processed message : [{myQueueItem}]");
// int i = tableBinding.Count();
// log.Info($"{i}");
foreach (Person person in tableBinding.Where(p => p.PartitionKey == myQueueItem)
.ToList())
{
log.Info($"RowKey: [{person.RowKey}]");
log.Info($"Categories: [{person.Categories}]");
}
}
public class Person : TableEntity
{
// public string PartitionKey { get; set; }
public string RowKey { get; set; } // !!!!!!!!!!!!!!!!!
// public string Timestamp { get; set; }
public string Categories { get; set; }
}
最佳答案
您继承的
TableEntity
类已经有一个名为 RowKey
的属性,因此..您的 Person
类不需要定义属性称为 RowKey
,它已经通过其基类拥有它。
您在这里所需要做的就是从 Person
类中删除 RowKey
属性,无需进行其他更改。
关于azure - 当我使用带有存储表的输入绑定(bind)时,如何访问 RowKey(和 PartitionKey)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45893501/