假设我在DocumentDB中有3个这样的对象。
这是类(class)记录。
现在,我想让所有有学生存在的ID都以Sunny命名。
{
"id": "111",
"class": 1,
"students": [
{
"name": "sunny"
},
{
"name": "pinki"
},
{
"name": "bobby"
},
{
"name": "lucky"
}
]
}
{
"id": "222",
"class": 2,
"students": [
{
"name": "pinki"
},
{
"name": "sunny"
},
{
"name": "bobby"
}
]
}
{
"id": "333",
"class": 3,
"students": [
{
"name": "pinki"
},
{
"name": "lucky"
},
{
"name": "bobby"
}
]
}
查询将得到什么结果?
最佳答案
您可以使用DocumentDB的JOIN
在具有数组元素的文档上创建叉积。
例如,以下查询在具有students
属性的文档上创建跨产品,以查询students.name
:
select doc.id
from doc
join students in doc.students
where students.name = 'sunny'
返回以下数据集:
[{
id: 111
}, {
id: 222
}]
引用:http://azure.microsoft.com/en-us/documentation/articles/documentdb-sql-query/#joins
关于c# - 如何基于内部json对象值在DocumentDB中进行查询?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28985470/