这是我的申请文件
{
"_id": "binary_stuff",
"Name": "MyApplication",
"Settings": [
{
"_id": "binary_stuff",
"Key": "ImportDirectory",
"Value": "C:\data",
"Overrides": [{
"_id": "binary_stuff",
"NewValue": "C:\anotherData"
}]
},
}
我知道如何添加一个Settings子文档但是如何添加一个新的Override“subsubdocument”。
我试过了:
var query = Query.And(Query.EQ("_id", applicationId), Query.EQ("Settings._id", settingId));
var update = Update.AddToSetWrapped("Settings.Overrides", overrideViewModel.ToBsonDocument());
Run(database => database.Applications().Update(query, update, UpdateFlags.Upsert, SafeMode.True));
它没有任何作用......
任何帮助都将不胜感激。
谢谢你们!
答案 0 :(得分:0)
我找到了答案,我不得不使用操作$
var query = Query.And(Query.EQ("_id", applicationId), Query.EQ("Settings._id", settingId));
var update = Update.AddToSetWrapped("Settings.Overrides", overrideViewModel.ToBsonDocument());
Run(database => database.Applications().Update(query, update, UpdateFlags.Upsert, SafeMode.True));