CrazyBernie
CrazyBernie

Reputation: 174

Azure Document Query Sub Dictionaries

I have stored the following JSON document in the Azure Document DB:

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

When i try to query the document back i can easily perform the

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

However when i try to query: Select f.id,f.Properties, C.Key from f Join C IN f.Properties where C.Value = 'testing1'

I get an error that the query cannot be computed. I assume this is due to 'VALUE' being a reserved keyword within the query language.

I cannot specify a specific order in the property array because different subclasses can add different property in different orders as they need them.

Anybody any suggestion how i can still complete this query ?

Upvotes: 3

Views: 860

Answers (1)

Aravind Krishna R.
Aravind Krishna R.

Reputation: 8003

To escape keywords in DocumentDB, you can use the [] syntax. For example, the above query would be:

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

Upvotes: 5

Related Questions