Reputation: 4968
My filter string during a Table Query looks like below...
string FilterString = string.Format("PartitionKey eq '{0}'
and RowKey ge '{1}' and RowKey le '{2}'",
partitionKey, startsWith, startsWith);
https://msdn.microsoft.com/library/azure/dd894031.aspx says you can do prefix matching for names. Lets say there are 3 names...
I would like the query to return both superman and spiderman when I set the startsWith to 's'
The query above works when I say
RowKey ge 's' and Rowkey le 't'
However, I would like this to work when it says...
RowKey ge 's' and Rowkey le 's'
le is being treated as lt and IMHO it shouldn't have behaved the way it does. Am I doing something wrong?
Upvotes: 0
Views: 130
Reputation: 136136
If you want to get back superman
and spiderman
(not sure how DC & Marvel Comics would agree to that but that's another story :)), the query you want to issue is:
RowKey ge 's' and Rowkey lt 't'
Now let's consider this query:
RowKey ge 's' and Rowkey le 's'
Basically this query will only return data where RowKey
eq s
. To take an example, consider superman
. Now superman
is definitely greater than s
so your first expression (RowKey ge 's'
) is true
but at the same time your second expression (Rowkey le 's'
) is false
so the entire expression's result will be false
.
UPDATE
To test strings, you could simply write a console application like the following:
string a = "s";
string b = "superman";
string c = "sz";
Console.WriteLine(b.CompareTo(a));//Prints 1
Console.WriteLine(b.CompareTo(c));//Prints -1
As you can see from above, superman
is greater than s
and is lesser than sz
.
Upvotes: 1