将元素插入MongoDB中的3级深嵌套数组(C#驱动程序)

时间:2017-04-03 05:39:56

标签: c# mongodb insert nested mongodb-.net-driver

我有这个:

{  
   "_id":"2900f1e8-48fa-418b-8e4d-73a6592e5d41",

   "CollectionRequirement":[  
      {  
         "_id":"a6af03b1-8bb3-4cb2-b307-b8831e61ef7d",
         "RequirementName":"CENTCOM14CR-000000000024243T0500089",
         "RequestorID":"IMINT ORG 1",

         "Task":[  
            {  
               "_id":"705284be-492e-4744-8361-f977b81404e9",
               "TaskPriority":"1",

               "CollectionConstraint":[  
                  {  
                     "_id":"99ec8961-647e-45db-98c3-04a91866143e",
                     "SensorID":"ASARS-2A",
                     "SensorMode":"21"
                  }
               ]
            },
            {  
               "_id":"af8c7911-0aa3-4ce2-b399-7a997ecde38a",
               "TaskPriority":"2",

               "CollectionConstraint":[  
                  {  
                     "_id":"10ec8961-647e-45db-98c3-04a918661445",
                     "SensorID":"ASARS-2A",
                     "SensorMode":"25"
                  }
               ]
            }
         ]
      }
   ]
}

我想在任务下添加一个新的 CollectionConstraint ,其中" TaskPriority == 1" 使用C#驱动程序。有没有办法做到这一点?

我在其他帖子中看到了一些示例代码,但这些示例仅适用于2级嵌套数组。例如,请参阅此帖子:Insert element into nested array in Mongodb

0 个答案:

没有答案