MongoDB:如何在 C# 中加载带有嵌套数组的集合?
我有一个名为“服务器”的集合,其中包含以下文档。
{
name: "West",
ip: "123.123.123.123",
channels:
[
{
name: "English",
port: "1234",
status: "0"
},
{
name: "Spanish",
port: "1235",
status: "0"
},
{
name: "German",
port: "1236",
status: "0"
}
]
},
{
name: "East",
ip: "122.122.122.122",
channels:
[
{
name: "English",
port: "1234",
status: "0"
},
{
name: "French",
port: "1235",
status: "0"
}
]
}
我如何使用 C# 使用结构从 MongoDB 中选择它?
I have collection called "servers" with following documents.
{
name: "West",
ip: "123.123.123.123",
channels:
[
{
name: "English",
port: "1234",
status: "0"
},
{
name: "Spanish",
port: "1235",
status: "0"
},
{
name: "German",
port: "1236",
status: "0"
}
]
},
{
name: "East",
ip: "122.122.122.122",
channels:
[
{
name: "English",
port: "1234",
status: "0"
},
{
name: "French",
port: "1235",
status: "0"
}
]
}
How would I select that from MongoDB using C# using structures?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要所有项目,您可以使用以下代码:
但是如果您想要例如 name = west 的所有文档,则可以:
ServerItem:
If you want all items you can use follwoing code:
But if you want for example all documents with name = west, than you can:
ServerItem: