Skip to content
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

docsp-27681 - move example classes #150

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions source/usage-examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
Usage Examples
==============

.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code, .NET, operation

.. contents:: On this page
:local:
:backlinks: none
Expand Down Expand Up @@ -60,3 +67,26 @@ your MongoDB instance:

For more information about connecting to your MongoDB instance, see the
:ref:`Connection Guide <csharp-connection>`.

Example Classes
---------------

The usage examples in this section use the following ``Restaurant``, ``Address``, and
``GradeEntry`` classes as models:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: in this introduction, mention the db/collection as well, to provide some context. Perhaps something like:

Suggested change
The usage examples in this section use the following ``Restaurant``, ``Address``, and
``GradeEntry`` classes as models:
The usage examples in this section demonstrate how to perform operatons on documents in the
``restaurants`` collection. The examples use the following ``Restaurant``, ``Address``, and
``GradeEntry`` classes to model the data in this collection:

Or, you can add this information to the first sentence earlier in this file that says "These examples use the
sample datasets provided by Atlas." because this suggests that the examples use more than one collection, but its seems like they all use the restaurants collection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the first option still suggests that the restaurants collection is part of the Atlas sample datasets, so I went with that


.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst
30 changes: 6 additions & 24 deletions source/usage-examples/deleteMany.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Delete Many Documents
=====================

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -15,29 +20,6 @@ Delete Many Documents
You can delete more than one document using the ``DeleteMany()`` synchronous
method or the ``DeleteManyAsync()`` asynchronous method on a collection object.

Example
-------
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I: I think you should consider leaving this heading in all of the usage examples, since removing it makes it so that the tree navigation on some of the pages starts with "Expected Result" like here and here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought


The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

The following code deletes all documents in the ``restaurants`` collection whose
``borough`` field value equals the word "Brooklyn".

Expand Down
30 changes: 6 additions & 24 deletions source/usage-examples/deleteOne.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Delete a Document
=================

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -22,29 +27,6 @@ You can delete a document from a collection by using the synchronous

To learn more about using ``DeleteMany()``, see :ref:`csharp-delete-many`.

Examples
--------

The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

Delete a Document Using Builders
mongoKart marked this conversation as resolved.
Show resolved Hide resolved
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
30 changes: 6 additions & 24 deletions source/usage-examples/findMany.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Find Multiple Documents
=======================

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -15,29 +20,6 @@ Find Multiple Documents
You can retrieve multiple documents from a collection by using the
``Find()`` method.

Examples
--------

The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

Find Documents Using Builders
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
30 changes: 6 additions & 24 deletions source/usage-examples/findOne.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Find a Document
===============

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -14,29 +19,6 @@ Find a Document

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

Examples
--------

The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

Find a Document Using Builders
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
30 changes: 6 additions & 24 deletions source/usage-examples/insertMany.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Insert Multiple Documents
=========================

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -15,29 +20,6 @@ Insert Multiple Documents
You can insert multiple documents into a collection by using the synchronous
``InsertMany()`` method or the asynchronous ``InsertManyAsync()`` method.

Examples
--------

The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

The following example inserts multiple documents into
the ``restaurants`` collection.

Expand Down
33 changes: 7 additions & 26 deletions source/usage-examples/insertOne.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Insert a Document
=================

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -15,31 +20,7 @@ Insert a Document
You can insert a single document into a collection by using the synchronous
``InsertOne()`` method, or the asynchronous ``InsertOneAsync()`` method.

Examples
--------

The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

The following example inserts a document into
the ``restaurants`` collection.
The following example inserts a document into the ``restaurants`` collection.

Select the :guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the
corresponding code.
Expand Down
30 changes: 6 additions & 24 deletions source/usage-examples/replaceOne.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Replace a Document
==================

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -15,29 +20,6 @@ Replace a Document
You can replace one document with another by using the ``ReplaceOne()`` synchronous method
or the ``ReplaceOneAsync()`` asynchronous method on a collection object.

Example
-------

The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

The following code replaces the first document in the ``restaurants`` collection that has a
value of "Pizza" in the ``cuisine`` field. After the replacement, this document will
have a ``name`` field with a value of "Mongo's Pizza" and new values for the
Expand Down
30 changes: 6 additions & 24 deletions source/usage-examples/updateMany.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Update Many Documents
=====================

.. default-domain:: mongodb
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code example, .NET, operation

.. contents:: On this page
:local:
Expand All @@ -15,29 +20,6 @@ Update Many Documents
You can update more than one document using the ``UpdateMany()`` method on
a collection object.

Example
-------

The examples on this page use the following ``Restaurant``, ``Address``, and ``GradeEntry``
classes as models:

.. literalinclude:: /includes/code-examples/Restaurant.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/Address.cs
:language: csharp
:copyable:
:dedent:

.. literalinclude:: /includes/code-examples/GradeEntry.cs
:language: csharp
:copyable:
:dedent:

.. include:: /includes/convention-pack-note.rst

The following code updates all documents in the ``restaurants`` collection that have a
mongoKart marked this conversation as resolved.
Show resolved Hide resolved
``cuisine`` field with the value of "Pizza". After the update, these documents will
have a ``cuisine`` field with a value of "Pasta and breadsticks".
Expand Down
Loading
Loading