Skip to content

Commit 21a2fc3

Browse files
authored
Merge pull request #2 from mongoKart/quickstart
[DOCSP-24527] Quick Start page
2 parents f324f4d + a3271fa commit 21a2fc3

11 files changed

+188
-7
lines changed

snooty.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ intersphinx = [
1414
sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
1515

1616
[constants]
17-
driver-long = "MongoDB C#/.NET Driver"
17+
driver-long = "MongoDB .NET/C# Driver"
18+
driver-short = ".NET/C# Driver"
19+
lang-framework = ".NET/C#"
20+
language = "C#"
1821
docs-branch = "master" # always set this to the docs branch (i.e. master, 1.7, 1.8, etc.)
1922
version = "v2.17" # always set this to the driver branch (i.e. v1.7.0, v1.8.0, etc.)
2023
example = "https://raw.githubusercontent.com/mongodb/docs-csharp/{+docs-branch+}/source/includes/usage-examples/code-snippets"
502 KB
Loading
77.7 KB
Loading

source/includes/language-compatibility-table-csharp.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
.. list-table::
32
:header-rows: 1
43
:stub-columns: 1
54
:class: compatibility-large no-padding
65

7-
* - C#/.NET Driver Version
6+
* - {+driver-short+} Version
87
- .NET 5/6 [#atlas-connection]_
98
- .NET Core 3.1
109
- .NET Core 3.0
@@ -262,8 +261,8 @@ through 4.8 only.
262261

263262
.. [#atlas-connection] When using .NET 5/6, you can't connect to Atlas clusters running MongoDB 4.0 due to a certificate issue. This does not impact clusters running MongoDB 4.2+.
264263
265-
.. [#2.14-note] .NET/C# driver versions 2.14 or later requires .NET Framework 4.7.2 or
264+
.. [#2.14-note] {+driver-short+} versions 2.14 or later requires .NET Framework 4.7.2 or
266265
later.
267266
268-
.. [#4.5.2] .NET/C# driver versions 2.8 to 2.13 requires .NET Framework 4.5.2 or later.
267+
.. [#4.5.2] {+driver-short+} versions 2.8 to 2.13 requires .NET Framework 4.5.2 or later.
269268

source/includes/mongodb-compatibility-table-csharp.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
.. include:: /includes/compatibility-table-legend.rst
21
.. list-table::
32
:header-rows: 1
43
:stub-columns: 1
54
:class: compatibility-large
65

7-
* - C#/.NET Driver Version
6+
* - {+driver-short+} Version
87
- MongoDB 6.0
98
- MongoDB 5.0
109
- MongoDB 4.4
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using MongoDB.Driver;
2+
using MongoDB.Bson;
3+
4+
string? connectionString = System.Environment.GetEnvironmentVariable("MONGODB_URI");
5+
if (connectionString == null)
6+
{
7+
Console.WriteLine("You must set your 'MONGODB_URI' environmental variable. See\n\t https://www.mongodb.com/docs/drivers/go/current/usage-examples/#environment-variable");
8+
Environment.Exit(0);
9+
}
10+
11+
var client = new MongoClient(connectionString);
12+
13+
var collection = client.GetDatabase("sample_mflix").GetCollection<BsonDocument>("movies");
14+
15+
var filter = Builders<BsonDocument>.Filter.Eq("title", "Back to the Future");
16+
17+
var document = collection.Find(filter).First();
18+
19+
Console.WriteLine(document);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Set up a Free Tier Cluster in Atlas
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
After setting up your .NET project dependencies, create a MongoDB cluster
5+
where you can store and manage your data. Complete the
6+
:atlas:`Get Started with Atlas </getting-started>` guide to set up a new
7+
Atlas account and free tier MongoDB cluster, load datasets, and
8+
interact with the data.
9+
10+
After completing the steps in the Atlas guide, you have a new MongoDB
11+
cluster deployed in Atlas, a new database user, and
12+
:atlas:`sample datasets loaded </sample-data/>` into your cluster.
13+
14+
.. _csharp-connect-to-your-cluster:
15+
16+
Connect to Your Cluster
17+
-----------------------
18+
19+
In this step, you'll create and run an application that uses the {+driver-short+} to connect to your MongoDB cluster and run a query on the sample data.
20+
21+
You pass instructions to the driver on where and how to connect to your
22+
MongoDB cluster in a string called the *connection string*. This string
23+
includes information on the hostname or IP address and port of your
24+
cluster, authentication mechanism, user credentials (when applicable), and
25+
other connection options.
26+
27+
To retrieve your connection string for the cluster and user you created in
28+
the previous step, log into your Atlas account and navigate to the
29+
**Clusters** section, then click the **Connect** button for the cluster that you
30+
want to connect to, as shown below.
31+
32+
.. figure:: /includes/figures/atlas_connection_select_cluster.png
33+
:alt: Atlas Connection GUI cluster selection screen
34+
35+
Proceed to the **Connect Your Application** step and select the {+driver-short+}. Then, click the **Copy** button to copy the *connection string*
36+
to your clipboard as shown below.
37+
38+
.. figure:: /includes/figures/atlas_connection_copy_string.png
39+
:alt: Atlas Connection GUI connection string screen
40+
41+
Save your Atlas connection string in a safe location that you can access
42+
for the next step.
43+
44+
To learn more about connecting to the {+driver-short+} through Atlas, see
45+
the :atlas:`Atlas driver connection guide </driver-connection>`
46+
and select **C#** from the *Select your language* dropdown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Learn how to read and modify data using the {+driver-short+} in our Fundamentals
2+
CRUD guide or how to perform common operations from our
3+
:ref:`csharp-usage-examples`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This guide shows you how to create an application that uses the **.NET/C# Driver**
2+
to connect to a **MongoDB Atlas cluster**. If you prefer to connect to MongoDB
3+
using a different driver or programming language, see our
4+
:driver:`list of official MongoDB drivers <>`.
5+
6+
The .NET/C# driver lets you connect to and communicate with MongoDB clusters
7+
from a .NET application.
8+
9+
MongoDB Atlas is a fully-managed cloud database service that hosts your data
10+
on MongoDB clusters. In this guide, we show you how to get started with your
11+
own free (no credit card required) cluster.
12+
13+
Follow the steps below to connect your .NET application with a MongoDB Atlas
14+
cluster.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
When you run ``Program.cs``, it should output the details of the following movie from
2+
the sample dataset:
3+
4+
.. code-block:: json
5+
6+
{
7+
"_id": "573a1398f29313caabce9682",
8+
...
9+
"title": "Back to the Future",
10+
...
11+
}

0 commit comments

Comments
 (0)