我有这个带有guid id的集合.当我使用Azure Query Explorer并在上面的组合框中选择了集合时,它可以:
SELECT * FROM c
但是当我尝试选择它时(来自查询exlorer和c#代码):
SELECT * FROM 357fa002-dc7d-4ede-935a-6a0c80cf9239 c
我明白了:
Syntax error, invalid numeric value token ‘357fa002’.
我试过把它放在guid附近的引号(单引号和双引号)但没有成功..
Microsoft文档声明此集合ID不会破坏任何规则:
https://docs.microsoft.com/pl-pl/azure/documentdb/documentdb-create-collection
Collection names must be between 1 and 255 characters, and cannot contain / \ # ? or a trailing space
如何使用它的id查询此集合?
解决方法:
根据你的描述,我检查了有关FROM clause DocumentDB SQL语法的官方文档.以下是上述文档的语法:
FROM <from_specification>
<from_specification> ::=
<from_source> {[ JOIN <from_source>][,...n]}
<from_source> ::=
<collection_expression> [[AS] input_alias]
| input_alias IN <collection_expression>
<collection_expression> ::=
ROOT
| collection_name
| input_alias
| <collection_expression> '.' property_name
| <collection_expression> '[' "property_name" | array_index ']'
对于< collection_expression>,我们可以指定当前连接到的集合的名称.
根据您的情况,我在我身边试了一下并重现了这个问题.此外,我已经测试了这个问题,发现input_alias或collection_name只能由数字和字母组成,第一个必须是一个字母.经过我的测试,我认为到目前为止你无法达到这个目的.我会报告此问题,您可以添加您的反馈here.
更新:
对于C#的客户端libarary Microsoft Azure DocumentDB,我们可以在调用DocumentClient.CreateDocumentQuery时使用Fiddler捕获请求,而不指定sqlExpression参数,如下所示:
var items =
client.CreateDocumentQuery<GroupedSales>(UriFactory.CreateDocumentCollectionUri(DatabaseId,
DocumentCollectionId)).Where(
x =>
x.Date >= filter.From.Date
&& x.Date <= filter.To.Date
).ToList();
注意:如果没有Where子句,请求正文将为空.此时,查询等于“SELECT * FROM root”.
原文地址:https://codeday.me/bug/20190519/1133925.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。