0
我對Azure表存儲非常陌生,分區鍵的概念仍然是一個我還沒有信心知道我是否正確進行的區域。以下是我提出的用於存儲博客文章評論數據的解決方案。我已經評論過所有的東西,所以我希望我的想法是基於代碼的自我解釋。Azure表存儲:爲備註數據配置分區和行鍵的最佳方法?
- 行和分區鍵看起來好嗎?
- 我真的需要一個名爲「CommentId?」的字段嗎? (在我看到的例子中,似乎沒有具體的ID字段,就像傳統SQL存儲中的字段一樣。
- 表的範圍應該是什麼?(我目前設想所有博客文章中的所有評論都有一張表。)
感謝我可能沒有考慮任何的想法...
-Ben
public class CommentEntity : TableEntity
{
/// <summary>
///
/// </summary>
/// <param name="CommentId">Unique identifier for the comment</param>
/// <param name="ReferencedBlogPostId">Identifier representing the post which this comment references</param>
public CommentEntity(int CommentId, int ReferencedBlogPostId)
{
this.PartitionKey = ReferencedBlogPostId.ToString();
this.RowKey = CommentId.ToString();
}
public CommentEntity() { }
// public int CommentId { get; set; } (Moved to above constructor)
// public int ReferencedBlogPostId { get; set; } (Moved to constructor)
//If this is in reply to another comment, reference that CommentId here
public int ParentCommentId { get; set; }
//Time that the post was made
public DateTime PostedTime { get; set; }
//An Id value representing the author of the comment in another datastore
public int AuthorId { get; set; }
}
謝謝肖恩。你能否爲我澄清一下,我是否有責任在創建Comment對象時創建CommentId? – BenjiFB
我這麼認爲,BenjiFB –