Docs 主页 → 开发应用程序 → MongoDB 驱动程序 → C#/.NET
查找多个文档
您可以使用 Find()
方法从集合中检索多个文档。
例子
使用构建器查找文档
以下示例使用 Builders
在 restaurants
集合中查找包含 cuisine
"Pizza" 的文档。
选择 Asynchronous 或 Synchronous 标签页,查看相应的代码。
使用 LINQ 查找文档
以下示例使用 LING 在 restaurants
集合中查找包含 cuisine
"Pizza" 的文档。
选择 Asynchronous 或 Synchronous 标签页,查看相应的代码。
查找所有文档
以下示例在 restaurants
集合中查找所有文档。
选择 Asynchronous 或 Synchronous 标签页,查看相应的代码。
预期结果
运行上述完整示例将打印以下结果:
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。