当我使用存储表的输入绑定时,如何访问RowKey(和PartitionKey)?

Ste*_*veC 2 azure azure-storage azure-table-storage azure-functions

当我使用带有存储表的输入绑定而没有错误"隐藏继承的成员'TableEntity.RowKey"时,如何访问RowKey(和PartitionKey)?

我可以愉快地基于PartitionKey访问类别,但是当我尝试扩展到获取RowKey时,通过向我的类添加新属性,我收到错误... warning CS0108: 'Person.RowKey' hides inherited member 'TableEntity.RowKey'. Use the new keyword if hiding was intended.

#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; }
}
Run Code Online (Sandbox Code Playgroud)

Dog*_*lan 6

TableEntity你继承的类已经有一个叫做的属性RowKey,所以..你的Person类不需要定义一个被调用的属性RowKey,它已经通过它的基类得到它了.

您需要做的就是RowKeyPerson班级中删除属性,不需要进行其他更改.