File tree Expand file tree Collapse file tree 1 file changed +1
-41
lines changed Expand file tree Collapse file tree 1 file changed +1
-41
lines changed Original file line number Diff line number Diff line change 4
4
Quick Reference
5
5
===============
6
6
7
- .. default-domain:: mongodb
8
-
9
7
This page shows the driver syntax for several MongoDB commands and links to
10
- their related reference and API documentation. The examples in this guide use the
11
- ``restaurants`` collection from the ``sample_restaurants`` database, part of the
12
- :atlas:`sample datasets </sample-data>` provided by Atlas.
13
- See the :ref:`<csharp-quickstart>` to learn how to create a free MongoDB cluster
14
- and load this sample data.
15
-
16
- The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
17
- classes as models:
18
-
19
- .. literalinclude:: /includes/code-examples/Restaurant.cs
20
- :language: csharp
21
- :copyable:
22
- :dedent:
23
-
24
- .. literalinclude:: /includes/code-examples/Address.cs
25
- :language: csharp
26
- :copyable:
27
- :dedent:
28
-
29
- .. literalinclude:: /includes/code-examples/GradeEntry.cs
30
- :language: csharp
31
- :copyable:
32
- :dedent:
33
-
34
- After you've loaded the sample data into your MongoDB instance, you can use the
35
- following code to access the ``restaurants`` collection:
36
-
37
- .. code-block:: csharp
38
- :copyable: true
39
-
40
- using MongoDB.Driver;
41
-
42
- var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
43
- ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
44
-
45
- const string connectionUri = "<your MongoDB connection URI>";
46
- var client = new MongoClient(connectionUri);
47
- var restaurantsDatabase = mongoClient.GetDatabase("sample_restaurants");
48
- _restaurantsCollection = restaurantsDatabase.GetCollection<Restaurant>("restaurants");
8
+ their related reference and API documentation.
49
9
50
10
.. tip:: Using LINQ
51
11
You can’t perform that action at this time.
0 commit comments