当我将输入绑定与存储 Table 一起使用时,如何访问 RowKey(和 PartitionKey)?
How can I access the RowKey (and PartitionKey) when I use a input binding with a storage Table?
当我将输入绑定与存储 Table 一起使用时如何访问 RowKey(和 PartitionKey)而不出现错误 "hides inherited member 'TableEntity.RowKey"?
我可以愉快地访问基于 PartitionKey 的类别,但是当我尝试通过向我的 class 添加一个新的 属性 来扩展以获取 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; }
}
您继承的 TableEntity
class 已经有一个名为 RowKey
的 属性,所以..您的 Person
class 没有需要定义一个名为 RowKey
的 属性,它已经通过其基数 class.
拥有它
您在这里需要做的就是从您的 Person
class 中删除 RowKey
属性,无需进行其他更改。
当我将输入绑定与存储 Table 一起使用时如何访问 RowKey(和 PartitionKey)而不出现错误 "hides inherited member 'TableEntity.RowKey"?
我可以愉快地访问基于 PartitionKey 的类别,但是当我尝试通过向我的 class 添加一个新的 属性 来扩展以获取 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; }
}
TableEntity
class 已经有一个名为 RowKey
的 属性,所以..您的 Person
class 没有需要定义一个名为 RowKey
的 属性,它已经通过其基数 class.
您在这里需要做的就是从您的 Person
class 中删除 RowKey
属性,无需进行其他更改。