Table 在 Azure 中查询
Table Query in Azure
我在 Table 查询期间的过滤字符串如下所示...
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 表示您可以对名称进行前缀匹配。假设有 3 个名字...
- 蝙蝠侠
- 超人
- 蜘蛛侠
当我将 startsWith 设置为 's'
时,我想查询 return 超人和蜘蛛侠
上面的查询在我说
时有效
RowKey ge 's' and Rowkey le 't'
但是,我希望它能在它说...
RowKey ge 's' and Rowkey le 's'
le 被视为 lt 恕我直言,它不应该像现在这样。我做错了什么吗?
如果您想返回 superman
和 spiderman
(不确定 DC 和 Marvel Comics 会如何同意,但那是另一回事 :)),您要发出的查询是:
RowKey ge 's' and Rowkey lt 't'
现在让我们考虑这个查询:
RowKey ge 's' and Rowkey le 's'
基本上这个查询只会 return 数据,其中 RowKey
eq s
。举个例子,考虑 superman
。现在 superman
肯定大于 s
所以你的第一个表达式 (RowKey ge 's'
) 是 true
但同时你的第二个表达式 (Rowkey le 's'
) 是 false
所以整个表达式的结果将是 false
。
更新
要测试字符串,您只需编写如下所示的控制台应用程序:
string a = "s";
string b = "superman";
string c = "sz";
Console.WriteLine(b.CompareTo(a));//Prints 1
Console.WriteLine(b.CompareTo(c));//Prints -1
从上面可以看出,superman
大于s
小于sz
。
我在 Table 查询期间的过滤字符串如下所示...
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 表示您可以对名称进行前缀匹配。假设有 3 个名字...
- 蝙蝠侠
- 超人
- 蜘蛛侠
当我将 startsWith 设置为 's'
时,我想查询 return 超人和蜘蛛侠上面的查询在我说
时有效RowKey ge 's' and Rowkey le 't'
但是,我希望它能在它说...
RowKey ge 's' and Rowkey le 's'
le 被视为 lt 恕我直言,它不应该像现在这样。我做错了什么吗?
如果您想返回 superman
和 spiderman
(不确定 DC 和 Marvel Comics 会如何同意,但那是另一回事 :)),您要发出的查询是:
RowKey ge 's' and Rowkey lt 't'
现在让我们考虑这个查询:
RowKey ge 's' and Rowkey le 's'
基本上这个查询只会 return 数据,其中 RowKey
eq s
。举个例子,考虑 superman
。现在 superman
肯定大于 s
所以你的第一个表达式 (RowKey ge 's'
) 是 true
但同时你的第二个表达式 (Rowkey le 's'
) 是 false
所以整个表达式的结果将是 false
。
更新
要测试字符串,您只需编写如下所示的控制台应用程序:
string a = "s";
string b = "superman";
string c = "sz";
Console.WriteLine(b.CompareTo(a));//Prints 1
Console.WriteLine(b.CompareTo(c));//Prints -1
从上面可以看出,superman
大于s
小于sz
。