如何将RowKey设置为带序列的新值

时间:2011-07-18 11:33:25

标签: azure azure-storage azure-table-storage

我有以下课程:

public class Note : TableServiceEntity
{
    public Note( )
    {
    }

    public Note(string pK)
    {
        PartitionKey = pK,
        RowKey = Seq.GetSequence().ToString();
    }
    public string Description { get; set; }
}

我需要的是将RowKey设置为序列生成的值。任何人都可以解释如何使用构造函数执行此操作?我得到的是语法错误:Virtual member call in constructor

1 个答案:

答案 0 :(得分:0)

public static class Seq
{
   static int index;
   public static int GetSequence()
   {
      return index++;
   }
}

public class Note : TableServiceEntity
{
   public Note(string partitionKey, string rowKey) 
      : base(partitionKey, Seq.GetSequence().ToString()) { }
}