Reputation: 55
I'm aware that Azure Storage doesn't have a contains like filter in their current API. However, I also know that you can build a contains like filter for strings using code like the following:
TableQuery<TableEntity> Query = new TableQuery<TableEntity>()
.Where(
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.GreaterThanOrEqual, substring),
TableOperators.And,
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.LessThan, substring + someValue)
));
My Question is what should I use as someValue to make this equivalent to a contains?
I can't seem to find a chart online that indicates what char is the first char for all chars lexigraphically for c#. Is there any reason not to do this, and do the search on the client side? My partitionKey is well defined subgroups.
Thanks in advance!
Upvotes: 1
Views: 2404
Reputation: 30025
It actually uses the ascii
order to compare in the filter.
For example, if the substring
is good
, then in the second filter:
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.LessThan, "good" + someValue)
,
you should change it to
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.LessThan, "gooe")
There is no need to add someValue
. Just replace the last char for your substring, to the next ascii char.
Upvotes: 2