C# MongoDB将数组添加到BsonDocument
我正在尝试使用C#驱动程序在mongodb文档中添加字段 我正在创建一个文档C# MongoDB将数组添加到BsonDocument,c#,mongodb,mongodb-.net-driver,bson,C#,Mongodb,Mongodb .net Driver,Bson,我正在尝试使用C#驱动程序在mongodb文档中添加字段 我正在创建一个文档 BsonDocument document = new BsonDocument(); 及加入 document.Add(name, value); // here name and value both are string 但我不确定在这种情况下如何添加数组 像document.Add(名称、值);//这里的值是列表 e、 g.document.Add(技能,[C++,Java,C#]) 如果您使用的是列表,请
BsonDocument document = new BsonDocument();
及加入
document.Add(name, value); // here name and value both are string
但我不确定在这种情况下如何添加数组
像document.Add(名称、值);//这里的值是列表
e、 g.document.Add(技能,[C++,Java,C#])代码>
如果您使用的是列表,请帮助我:
你读过这个吗?是的,我看过这个页面,但没有直接的内容。。。。。我不确定通过一些工作我是否能做到这一点。。。。
var skills = new List<string> {"C++", "Java", "C#"};
document.Add("skills", new BsonArray(skills));
document.Add("skills", new BsonArray { "C++", "Java", "C#" } );