9

我怀疑是这样,因为抽象类 TableServiceEntity 具有以下内容:

    public virtual string PartitionKey { get; set; }
    public virtual string RowKey { get; set; }

如果我想要一个 DateTime 或 Double 类型的 RowKey 怎么办?

4

1 回答 1

19

是的,这些都是字符串。

如果您希望 RowKey 是 DateTime 或 Double ,那么您必须使用字符串表示。

有一些常见的模式。对于 DateTime,通常会看到 DateTime 使用方便排序的字符串表示:

  • DateTime.Ticks.ToString("d19")

或者

  • (DateTime.MaxValue.Ticks - DateTime.Ticks).ToString("d19")

请参阅史蒂夫马克思的这篇博客文章 - http://blog.smarx.com/posts/using-numbers-as-keys-in-windows-azure

于 2011-03-21T07:45:11.103 回答