【问题标题】:Azure Document Query Sub DictionariesAzure 文档查询子词典
【发布时间】:2015-02-01 17:41:19
【问题描述】:

我在 Azure 文档数据库中存储了以下 JSON 文档:

"JobId": "04e63d1d-2af1-42af-a349-810f55817602",
"JobType": 3,
"
"Properties": [
  {
    "Key": "Value1",
    "Value": "testing1"
  },
  {
    "Key": "Value",
    "Value": "testing2"
  }
]

当我尝试查询文档时,我可以轻松地执行

Select f.id,f.Properties, C.Key from f Join C IN f.Properties where C.Key = 'Value1'

但是,当我尝试查询时: 选择 f.id,f.Properties, C.Key from f Join C IN f.Properties where C.Value = 'testing1'

我收到无法计算查询的错误。我认为这是因为“VALUE”是查询语言中的保留关键字。

我无法在属性数组中指定特定的顺序,因为不同的子类可以根据需要以不同的顺序添加不同的属性。

有人建议我如何仍然可以完成此查询吗?

【问题讨论】:

    标签: azure azure-cosmosdb


    【解决方案1】:

    要在 DocumentDB 中转义关键字,您可以使用 [] 语法。例如,上面的查询将是:

    Select f.id,f.Properties, C.Key from f Join C IN f.Properties where C["Value"] = 'testing1'
    

    【讨论】:

      猜你喜欢
      • 2020-07-16
      • 2013-09-12
      • 2015-04-27
      • 1970-01-01
      • 2017-11-18
      • 2019-12-28
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多