Reputation: 622
I am using Azure table storage which provides very less options to query the table storage. I have my RowKey as a composed key in the following way:
"b844be0d-2280-49f7-9ad7-58c36da80d22_2518908336099522182"
,"b844be0d-2280-49f7-9ad7-58c36da80d22_2518908336099522183"
,"b844be0d-2280-49f7-9ad7-58c36da80d22_2518908336099522184"
,"b844be0d-2280-49f7-9ad7-58c36da80d22_2518908336099522185"
The first part is a Guid, and the second part after the separator(_) is the timeticks.
I want to search on azure storage using its operators for rowkeys ending with "2518908336099522182"
There is no "Contains" operator that can help here, What do i do to get it working for "EndsWith" kind of filtering?
Upvotes: 1
Views: 2628
Reputation: 11601
I assume that you want to search by date time, so you can put the date time value in front of your GUID to make the row key like this:
2518908336099522182_b844be0d-2280-49f7-9ad7-58c36da80d22
Next, when your search can be formulated like:
var filters = TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Smith"),
TableOperators.And,
TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, "2518908336099522182")
);
filters = TableQuery.CombineFilters(
filters,
TableOperators.And,
TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThanOrEqual, "2518908336099522182")
);
TableQuery<CustomerEntity> rangeQuery = new TableQuery<CustomerEntity>().Where(filters);
Hope this helps
Upvotes: 0
Reputation: 2513
Things to note: Both the PartitionKey and RowKey properties are of type String, you could filter the content through the use of $filter, or by Filtering on the PartitionKey and Rowkey as follows:
https://myaccount.table.core.windows.net/Customers(PartitionKey='MyPartition',RowKey='MyRowKey1')
another note: The constant value must be of the same data type as the property in order for the filter to return valid results. For more information about supported property types, see Understanding the Table Service Data Model.
In your case, as far as I know, the segmenting of a Rowkey then filtering on that is not an option of the supported operators. I'd recommend checking this link for the full documentation of supported queries.
Upvotes: 0