Docs Menu

Docs HomeDevelop ApplicationsMongoDB DriversC#/.NET

Update Many Documents

On this page

  • Example
  • Expected Result
  • More Information
  • API Documentation

You can update more than one document using the UpdateMany() method on a collection object.

The following code updates all documents in the restaurants collection that have a cuisine field with the value of "Pizza". After the update, these documents will have a cuisine field with a value of "Pasta and breadsticks".

Select the Asynchronous or Synchronous tab to see the corresponding code.

Running either of the preceding full examples prints the following results:

Restaurants with cuisine "Pizza" found: 1163
Restaurants modified by update: 1163
Restaurants with cuisine "Pasta and breadsticks" found after update: 1163
Resetting sample data...done.

To learn more about updating documents, see the Modify Documents guide.

To learn more about using builders, see Operations with Builders.

  • UpdateMany()

  • UpdateManyAsync()

  • UpdateOptions

  • UpdateResult

← Update a Document