I'm rounding down the current UTC date to the nearest minute and converting it to ticks to save the result as a PartitionKey
in Azure Table storage. I'd like to run a range query to get specific partition key ranges in code. I'm using C#, but clearly the below LINQ operations are not supported.
var tableQuery = cloudTable.CreateQuery<Log>().Where(x => long.Parse(x.PartitionKey) <= ticks);
throws
System.NotSupportedException: 'The expression (Parse([10007].PartitionKey) <= 637224147600000000) is not supported.'
I have also tried String.Compare()
, but it doesn't work either. So, how can I write a filtered query in C# to get records less than or equal to given ticks? Note that the partition key is chosen this way so that records can naturally be sorted in descending order of time.
x => x.PartitionKey <= ticks.toString()
? – Gaurav Mantri<=
when comparing a string to another string. That's why I usedString.Compare()
method, but it threw an exception as well. – user246392