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

标签 azure azure-storage azure-functions azure-table-storage

当我使用带有存储表的输入绑定(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/

相关文章:

azure - 从 Javascript 调用 Azure 函数

azure - Docker 推送给出 "blob upload unknown"

visual-studio - 如果VS 2017中新项目没有Cloud Option该怎么办?

azure - 自定义域在使用 Azure CDN 时出现错误 400

azure - “未配置文件端点。”当尝试使用模拟器在azure存储中使用文件客户端时

python - 如何在 python 中针对 Azure 存储 blob 对用户进行身份验证?

c# - Azure Function App v4 Blob 触发器并发

azure - 我看不到 Azure Function App 的代理

Azure 服务总线和长处理消息

c# - 如何使用 azure 存储表实现每秒 10 次以上的插入