Docs 主页 → 开发应用程序 → MongoDB 驱动程序 → C#/.NET
插入多个文档
您可以使用同步 InsertMany()
方法或异步 InsertManyAsync()
方法将单个文档插入集合中。
例子
以下示例将多个文档插入 restaurants
集合。
选择 Asynchronous 或 Synchronous 标签页,查看相应的代码。
预期结果
运行上述任一完整示例后,输出结果如下:
Number of restaurants found before insert: 0 Inserting documents... Number of restaurants inserted: 5
更多信息
如需了解有关使用生成器的更多信息,请参阅生成器操作。