开发者

Does PartitionKey and RowKey in Azure Table Storage have to be string?

I suspect so,开发者_开发百科 as the abstract class TableServiceEntity have the following:

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

What if I want a RowKey that is a DateTime or a Double?


yes, these are both strings.

If you want the RowKey to be a DateTime or a Double then you must use a string representation.

There are a few common patterns for this. For DateTime, it's common to see the DateTime represented using a string that is conveniently sorted:

  • DateTime.Ticks.ToString("d19")

or

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

See this blog post from Steve Marx - http://blog.smarx.com/posts/using-numbers-as-keys-in-windows-azure

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜