Krz*_*tof 5 c# azure azure-cosmosdb
我有这个带有guid id的集合.当我使用Azure Query Explorer并在上面的组合框中选择了集合时,它可以:
SELECT * FROM c
Run Code Online (Sandbox Code Playgroud)
但是当我尝试选择它时(来自查询exlorer和c#代码):
SELECT * FROM 357fa002-dc7d-4ede-935a-6a0c80cf9239 c
Run Code Online (Sandbox Code Playgroud)
我明白了:
语法错误,无效数值标记'357fa002'.
我试过把它放在guid附近的引号(单引号和双引号)但没有成功..
Microsoft文档声明此集合ID不会破坏任何规则:https: //docs.microsoft.com/pl-pl/azure/documentdb/documentdb-create-collection
集合名称必须介于1到255个字符之间,并且不能包含/ \#?或尾随空间
如何使用它的id查询此集合?
根据你的描述,我查了官方文档关于DocumentDB SQL语法的FROM子句。以下是上述文档中的语法:
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 ']'
Run Code Online (Sandbox Code Playgroud)
对于<collection_expression>,我们可以指定当前连接到的集合的名称。
根据您的情况,我在我这边尝试并重现了这个问题。另外,我测试过这个问题,发现input_aliasorcollection_name只能由数字和字母组成,并且第一个必须是字母。经过我的测试,我认为你到目前为止还无法实现这个目的。我会报告这个问题,您可以在此处添加您的反馈。
更新:
对于客户端库Microsoft Azure DocumentDB for C#,我们可以在调用时利用Fiddler来捕获请求,DocumentClient.CreateDocumentQuery而无需指定sqlExpression参数,如下所示:
var items =
client.CreateDocumentQuery<GroupedSales>(UriFactory.CreateDocumentCollectionUri(DatabaseId,
DocumentCollectionId)).Where(
x =>
x.Date >= filter.From.Date
&& x.Date <= filter.To.Date
).ToList();
Run Code Online (Sandbox Code Playgroud)

注意:如果没有该Where子句,请求正文将为空。此时,查询等于“SELECT * FROM root”。
| 归档时间: |
|
| 查看次数: |
685 次 |
| 最近记录: |