Docs 菜单

Docs 主页开发应用程序MongoDB 驱动程序C#/.NET

查找多个文档

在此页面上

  • 例子
  • 使用构建器查找文档
  • 使用 LINQ 查找文档
  • 查找所有文档
  • 预期结果
  • 更多信息
  • API 文档

您可以使用 Find() 方法从集合中检索多个文档。

以下示例使用 Buildersrestaurants 集合中查找包含 cuisine "Pizza" 的文档。

选择 AsynchronousSynchronous 标签页,查看相应的代码。

以下示例使用 LING 在 restaurants 集合中查找包含 cuisine "Pizza" 的文档。

选择 AsynchronousSynchronous 标签页,查看相应的代码。

以下示例在 restaurants 集合中查找所有文档。

选择 AsynchronousSynchronous 标签页,查看相应的代码。

运行上述完整示例将打印以下结果:

Finding documents with builders...:
Number of documents found: 1163
Finding documents with LINQ...:
Number of documents found: 1163
Finding all documents...:
Number of documents found: 25359

提示

样本数据集

这些示例使用 Atlas 提供的 样本数据集。返回的文档数量可能因集合中的数据而异。

如需了解有关检索文档的更多信息,请参阅“检索数据”指南。

如需了解有关使用生成器的更多信息,请参阅生成器操作

如需了解如何使用 LINQ 查找文档,请参阅 LINQ

  • find()

← 查找文档