我有一个文件,如下所示
这是我用C#为该文件设计的结构
public class MetaData
{
[BsonId]
public ObjectId _Id { get; set; }
[BsonElement("User")]
public IDictionary<Int64, FirstUser> User { get; set; }
}
public class FirstUser
{
[BsonElement("Name")]
public String Name { get; set; }
[BsonElement("Id")]
public Int64 Id { get; set; }
}
这是我为该文档设计的 BSON 结构。
/* 1 */
{
"_id" : ObjectId("5805c1ced520b54bd4192214"),
"User" : [
[
NumberLong(1),
{
"Name" : "FirstUser",
"_id" : NumberLong(1)
}
]
]
}
/* 2 */
{
"_id" : ObjectId("5805c1ced520b54bd4192215"),
"User" : [
[
NumberLong(1),
{
"Name" : "SecondUser",
"_id" : NumberLong(2)
}
]
]
}
/* 3 */
{
"_id" : ObjectId("5805c1ced520b54bd4192216"),
"User" : [
[
NumberLong(1),
{
"Name" : "ThirdUser",
"_id" : NumberLong(3)
}
]
]
}
/* 4 */
{
"_id" : ObjectId("5805c1ced520b54bd4192217"),
"User" : [
[
NumberLong(1),
{
"Name" : "FourthUser",
"_id" : NumberLong(2)
}
]
]
}
我需要所有名称为“FirstUser”的文档,我应该如何构建MONGO查询?