我创建了一个我在Compass中满意的查询。 数据可以导出到C#。 这是导出的数据:
new BsonArray
{
new BsonDocument("$unwind",
new BsonDocument("path", "$systemStations")),
new BsonDocument("$lookup",
new BsonDocument
{
{ "from", "Groups" },
{ "localField", "systemStations.stationGroups" },
{ "foreignField", "_id" },
{ "as", "systemStations.stationGroups" }
}),
new BsonDocument("$group",
new BsonDocument
{
{ "_id", "$_id" },
{ "systemName",
new BsonDocument("$first", "$systemName") },
{ "systemTimeZone",
new BsonDocument("$first", "$systemTimeZone") },
{ "SystemStations",
new BsonDocument("$push", "$systemStations") }
})
}
我不知道如何激活代码中的输出...
这是我的收藏集
DbSystems
现在如何激活文件管理器?
var filter = new BsonArray
{
new BsonDocument("$unwind",
new BsonDocument("path", "$systemStations")),
new BsonDocument("$lookup",
new BsonDocument
{
{ "from", "Groups" },
{ "localField", "systemStations.stationGroups" },
{ "foreignField", "_id" },
{ "as", "systemStations.stationGroups" }
}),
new BsonDocument("$group",
new BsonDocument
{
{ "_id", "$_id" },
{ "systemName",
new BsonDocument("$first", "$systemName") },
{ "systemTimeZone",
new BsonDocument("$first", "$systemTimeZone") },
{ "SystemStations",
new BsonDocument("$push", "$systemStations") }
})
};
DbSystems.Find(filter)