Young
Young

Reputation: 442

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?

Upvotes: 9

Views: 6045

Answers (1)

Stuart
Stuart

Reputation: 66882

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

Upvotes: 19

Related Questions