我有这个文件n级:查找嵌套子文档的MongoDB
{
"$id": "1",
"DocType": "Unidade",
"Nome": "TONY",
"RG_InscricaoEstadual": "4347924938742",
"Setores": [
{
"$id": "9",
"Nome": "Child0",
"Setores": [
{
"$id": "10",
"Nome": "Child1",
"Setores": [
/* <n depth nested level> */
"$id": "11",
"Nome": "Child2",
"Id": "90228c56-eff2-46d2-a324-b04e3c69e15c",
"DocType": "Setor"
],
"Id": "60228c56-dff2-46d2-a324-b04e3c69e15b",
"DocType": "Setor"
}
],
"Id": "8457e1b7-39dc-462c-8f46-871882faea2c",
"DocType": "Setor"
}
]
}
如果我想检索Setor如何查询该子文档,例如
"Id": "60228c56-dff2-46d2-a324-b04e3c69e15b"
我知道,如果我知道现在很多层次它是嵌套的,我可以写一个查询寻找类似的东西
Unidade.Setor.Id=="8457e1b7-39dc-462c-8f46-871882faea2c"
但是我怎样才能找到一个联合国已知数量的嵌套级别,例如1个,2个,3个n级别?
如何找到Setor与Id'90228c56-eff2-46d2-a324-b04e3c69e15c',例如?
关于如何解决这个问题的评论也将不胜感激。
好的答案,你可以添加一些使用C#LINQ sintax为MongoDB C#驱动程序查找的例子吗? – Tony
对不起,我是节点开发人员。我只能回答mongo的一部分。 –