-
Notifications
You must be signed in to change notification settings - Fork 24
TOC Reorg - Get Started #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.. _csharp-get-started: | ||
|
||
=================================== | ||
Get Started with the {+driver-short+} | ||
=================================== | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 2 | ||
:class: singlecol | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: tutorial | ||
|
||
.. meta:: | ||
:description: Learn how to create an app to connect to MongoDB deployment by using the .NET/C# driver. | ||
:keywords: quick start, tutorial, basics | ||
|
||
.. toctree:: | ||
|
||
Download the Driver </get-started/download-driver/> | ||
Deploy a Cluster </get-started/deploy-cluster/> | ||
Create a Connection String </get-started/create-connection-string/> | ||
Run a Sample Query </get-started/run-sample-query/> | ||
|
||
Overview | ||
-------- | ||
|
||
The {+driver-short+} is a NuGet package that you can use to connect | ||
to and communicate with MongoDB. This guide shows you how to create an | ||
application that uses the {+driver-short+} to connect to a MongoDB cluster hosted on | ||
MongoDB Atlas. | ||
|
||
.. tip:: | ||
|
||
MongoDB Atlas is a fully managed cloud database service that hosts your MongoDB | ||
deployments. You can create your own free (no credit card required) MongoDB Atlas | ||
deployment by following the steps in this guide. | ||
|
||
Follow this guide to connect a sample {+language+} application to a MongoDB Atlas | ||
deployment. If you prefer to connect to MongoDB using a different driver or | ||
programming language, see our :driver:`list of official drivers <>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
.. _csharp-get-started-connection-string: | ||
|
||
========================== | ||
Create a Connection String | ||
========================== | ||
|
||
You can connect to your MongoDB deployment by providing a | ||
**connection URI**, also called a *connection string*, which | ||
instructs the driver on how to connect to a MongoDB deployment | ||
and how to behave while connected. | ||
|
||
The connection string includes the hostname or IP address and | ||
port of your deployment, the authentication mechanism, user credentials | ||
when applicable, and connection options. | ||
|
||
.. tip:: | ||
|
||
To connect to a self-managed (non-Atlas) deployment, see | ||
:ref:`csharp-connect-to-mongodb`. | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Find your MongoDB Atlas Connection String | ||
|
||
To retrieve your connection string for the deployment that | ||
you created in the :ref:`previous step <csharp-get-started-deploy-cluster>`, | ||
log into your Atlas account and navigate to the | ||
:guilabel:`Database` section and click the :guilabel:`Connect` button | ||
for your new deployment. | ||
|
||
.. figure:: /includes/figures/atlas_connection_select_cluster.png | ||
:alt: The connect button in the clusters section of the Atlas UI | ||
|
||
Proceed to the :guilabel:`Connect your application` section and select | ||
"C# / .NET" from the :guilabel:`Driver` selection menu and the version | ||
that best matches the version you installed from the :guilabel:`Version` | ||
selection menu. | ||
|
||
Select the :guilabel:`Password (SCRAM)` authentication mechanism. | ||
|
||
Deselect the :guilabel:`Include full driver code example` option to view | ||
the connection string. | ||
|
||
.. step:: Copy your Connection String | ||
|
||
Click the button on the right of the connection string to copy it to | ||
your clipboard as shown in the following screenshot: | ||
|
||
.. figure:: /includes/figures/atlas_connection_copy_string.png | ||
:alt: The connection string copy button in the Atlas UI | ||
|
||
.. step:: Update the Placeholders | ||
|
||
Paste this connection string into a file in your preferred text editor | ||
and replace the ``<db_username>`` and ``<db_password>`` placeholders with | ||
your database user's username and password. | ||
|
||
Save this file to a safe location for use in the next step. | ||
|
||
.. step:: Set an Environment Variable | ||
|
||
In your shell, run the following code to save your MongoDB | ||
:ref:`connection string <csharp-connect-to-mongodb>` to an | ||
environment variable. Replace ``<your MongoDB URI>`` with the connection | ||
string that you saved to a file in the previous step. | ||
|
||
.. code-block:: bash | ||
|
||
export MONGODB_URI="<your MongoDB URI>" | ||
|
||
.. note:: PowerShell | ||
|
||
If you're using Microsoft PowerShell, run the following command instead: | ||
|
||
.. code-block:: bash | ||
|
||
set MONGODB_URI="<your MongoDB URI>" | ||
|
||
Storing your credentials in an environment variable is safer than hardcoding them | ||
in your source code. | ||
|
||
After completing these steps, you have a connection string that | ||
contains your database username and password. | ||
|
||
.. include:: /includes/get-started/quickstart-troubleshoot.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.. _csharp-get-started-deploy-cluster: | ||
|
||
============================== | ||
Deploy a MongoDB Atlas Cluster | ||
============================== | ||
|
||
You can create a free tier MongoDB deployment on MongoDB Atlas | ||
to store and manage your data. MongoDB Atlas hosts and manages | ||
your MongoDB database in the cloud. | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Create a Free MongoDB Deployment on Atlas | ||
|
||
Complete the :atlas:`Get Started with Atlas </getting-started>` | ||
guide to set up a new Atlas account and load sample data into a new free | ||
tier MongoDB deployment. | ||
|
||
.. step:: Save your Credentials | ||
|
||
After you create your database user, save that user's | ||
username and password to a safe location for use in an upcoming step. | ||
|
||
After you complete these steps, you have a new free tier MongoDB | ||
deployment on Atlas, database user credentials, and sample data loaded | ||
in your database. | ||
|
||
.. include:: /includes/get-started/quickstart-troubleshoot.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.. _csharp-get-started-download-driver: | ||
|
||
=========================== | ||
Download the {+driver-short+} | ||
=========================== | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Create a Project Directory | ||
|
||
In your shell, run the following commands to create a | ||
directory called ``csharp-quickstart`` and initialize a {+framework+} project for | ||
a new console application: | ||
|
||
.. code-block:: bash | ||
|
||
mkdir csharp-quickstart | ||
cd csharp-quickstart | ||
dotnet new console | ||
|
||
.. step:: Install the {+driver-short+} | ||
|
||
Run the following command to install the current version of the {+driver-short+} | ||
as a dependency of your project: | ||
|
||
.. code-block:: bash | ||
|
||
dotnet add package MongoDB.Driver | ||
|
||
After you complete these steps, you have a new {+framework+} project | ||
and the {+driver-short+} installed. | ||
|
||
.. include:: /includes/get-started/quickstart-troubleshoot.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.. _csharp-get-started-run-sample-query: | ||
|
||
================== | ||
Run a Sample Query | ||
================== | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Create your {+lang-framework+} Application | ||
|
||
Copy and paste the following code into the ``Program.cs`` file in your application: | ||
|
||
.. literalinclude:: /includes/quick-start/Program.cs | ||
:language: csharp | ||
:dedent: | ||
|
||
.. step:: Run your Application | ||
|
||
In your shell, run the following command to start this application: | ||
|
||
.. code-block:: sh | ||
|
||
dotnet run csharp-quickstart.csproj | ||
|
||
The output includes details of the retrieved movie document: | ||
|
||
.. code-block:: none | ||
|
||
{ | ||
_id: ..., | ||
plot: 'A young man is accidentally sent 30 years into the past...', | ||
genres: [ 'Adventure', 'Comedy', 'Sci-Fi' ], | ||
... | ||
title: 'Back to the Future', | ||
... | ||
} | ||
|
||
.. tip:: | ||
|
||
If you encounter an error or see no output, ensure that you specified the | ||
proper connection string, and that you loaded the | ||
sample data. | ||
|
||
After you complete these steps, you have a working application that | ||
uses the driver to connect to your MongoDB deployment, runs a query on | ||
the sample data, and prints out the result. | ||
|
||
.. include:: /includes/get-started/quickstart-troubleshoot.rst |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This page needs to be added to
snooty.toml
to make it clickable