Docs Menu

Docs HomeDevelop ApplicationsMongoDB DriversC#/.NET

Find a Document

On this page

  • Example
  • Find a Document by Using Builders
  • Find a Document by Using LINQ
  • Expected Result
  • Additional Information
  • API Documentation

You can retrieve a document by using the Find() method on a collection object.

The following example uses Builders to find a document in the restaurants collection that has a name field with a value of "Bagels N Buns".

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

The following example uses LINQ to find a document in the restaurants collection that has a name field with a value of "Bagels N Buns".

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

Running any of the preceding full examples prints results similar to the following:

{
"_id" : ObjectId("5eb3d668b31de5d588f42950"),
"name" : "Bagels N Buns",
"restaurant_id" : "40363427",
"cuisine" : "Delicatessen",
"address" : {...},
"borough" : "Staten Island",
"grades" : [...]
}

To learn more about retrieving documents, see the Retrieve Data guide.

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

To learn how to find a document using LINQ, see LINQ.

  • Find()

  • FirstOrDefault()

  • FirstOrDefaultAsync()

← Usage Examples