@@ -11,7 +11,7 @@ Create a MongoClient
1111
1212.. meta::
1313 :keywords: connection string, URI, server, Atlas, settings
14- :description: Learn how to create a ` MongoClient` to connect to a MongoDB deployment using a connection URI and customize connection behavior.
14+ :description: Learn how to create a MongoClient to connect to a MongoDB deployment URI and customize connection behavior.
1515
1616.. contents:: On this page
1717 :local:
@@ -25,15 +25,15 @@ deployment by using the {+driver-short+}.
2525Overview
2626--------
2727
28- To connect to a MongoDB deployment, you need two things :
28+ Connecting to a MongoDB deployment requires the following components :
2929
30- - A **connection URI**, also known as a *connection string*, which tells the {+driver-short+}
30+ - **Connection URI**, also known as a *connection string*, which tells the {+driver-short+}
3131 which MongoDB deployment to connect to.
32- - A **MongoClient** object, which creates the connection to the MongoDB deployment
33- and lets you perform operations on it .
32+ - **MongoClient** object, which creates and sustains the connection to the MongoDB deployment
33+ and lets you perform data operations .
3434
35- You can also use either of these components to customize the way {+driver-short+} behaves
36- while connected to MongoDB.
35+ You can also specify connection settings in either of these components to customize the way
36+ the {+driver-short+} behaves while connected to MongoDB.
3737
3838This guide shows you how to create a connection URI and use a ``MongoClient`` object
3939to connect to MongoDB.
@@ -65,7 +65,7 @@ A standard connection URI includes the following components:
6565 * - ``host[:port]``
6666
6767 - Required. The host and optional port number where MongoDB is running. If you don't
68- include the port number, the driver uses the default port, ``27017``.
68+ include the port number, the driver uses the default port ``27017``.
6969
7070 * - ``/defaultauthdb``
7171
@@ -90,15 +90,15 @@ MongoClient
9090
9191To create a connection to MongoDB, pass a connection URI to the
9292``MongoClient`` constructor. In the following example, the driver uses a sample
93- connection URI to connect to a MongoDB deployment running on port ``27017`` of ``localhost``:abbreviation:
93+ connection URI to connect to a MongoDB deployment running on port ``27017`` of ``localhost``:
9494
9595.. code-block:: csharp
9696
97- const string connectionUri = "mongodb://localhost:27017/";
98- var client = new MongoClient(connectionUri );
97+ const string uri = "mongodb://localhost:27017/";
98+ var client = new MongoClient(uri );
9999
100- Configuring the MongoClient
101- ---------------------------
100+ Configure the MongoClient
101+ -------------------------
102102
103103You can configure settings for the ``MongoClient`` object by passing a
104104``MongoClientSettings`` object to the constructor. The following example creates a
@@ -108,12 +108,11 @@ You can configure settings for the ``MongoClient`` object by passing a
108108
109109 var mongoClientSettings = MongoClientSettings
110110 .FromConnectionString("mongodb://localhost:27017/");
111- mongoClientSettings .UseTls = true;
111+ .UseTls = true;
112112 var client = new MongoClient(mongoClientSettings);
113113
114114For a full list of the settings you can configure, see the
115- `MongoClientSettings <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.MongoClientSettings.html>`_
116- API documentation.
115+ :ref:`csharp-connection-options` guide.
117116
118117API Documentation
119118-----------------
0 commit comments