2017-08-26 29 views
1

當我使用存儲表的輸入綁定而沒有錯誤「隱藏繼承的成員」TableEntity.RowKey「時,如何訪問RowKey(和PartitionKey)?當我使用存儲器表的輸入綁定時,如何訪問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; } 
} 
+0

關於爲什麼投票下降的任何反饋? ...這似乎不是一個完全愚蠢的問題,好吧,這是一個初學者的問題,但爲什麼投票呢? – SteveC

回答

5

TableEntity你繼承的類已經有一個名爲RowKey的屬性,所以..你的Person類不需要定義一個名爲RowKey的屬性,它已經通過它的基類。

您需要做的就是從Person類中刪除RowKey財產,不需要其他更改。

+0

謝謝,現在我明白你的意思了,很高興說它工作正常 – SteveC

相關問題