Skip to content

Commit 5c793d5

Browse files
committed
addressing basic comments
1 parent 7ba8930 commit 5c793d5

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

source/fundamentals/linq.txt

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ as follows:
7070
.. code-block:: csharp
7171
:emphasize-lines: 3
7272

73-
var restaurantsDatabase = client.GetDatabase("sample_restaurants");
74-
var restaurantsCollection = restaurantsDatabase.GetCollection<Restaurant>("restaurants");
75-
var queryableCollection = restaurantsCollection.AsQueryable();
73+
var restaurantsDatabase = client.GetDatabase("sample_restaurants");
74+
var restaurantsCollection = restaurantsDatabase.GetCollection<Restaurant>("restaurants");
75+
var queryableCollection = restaurantsCollection.AsQueryable();
7676

7777
The ``AsQueryable()`` method returns an `IMongoQueryable
7878
<{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Linq.IMongoQueryable.html>`__ instance that
@@ -591,12 +591,17 @@ in the Atlas manual and select :guilabel:`C#` from the language dropdown.
591591
Bitwise Operators
592592
~~~~~~~~~~~~~~~~~
593593

594-
This version of the {+driver-short+} supports the following bitwise operators in
595-
the aggregation pipeline. You can use multiple bitwise operators within the same
596-
stage. All operands must be of type ``int`` or ``long``. ``$bitAnd``, ``$bitOr``,
594+
The {+driver-short+} supports the use of the following
595+
`bitwise operators <https://en.wikipedia.org/wiki/Bitwise_operation>`__ in the
596+
aggregation pipeline. You can use multiple bitwise operators in the same
597+
stage. The following limits apply when using bitwise operators:
598+
599+
All operands must be of type ``int`` or ``long``. ``$bitAnd``, ``$bitOr``,
597600
and ``$bitXor`` all take two or more operands. ``$bitNot`` can only take one
598601
operand.
599602

603+
The bitwise operation will be evaluated from left to right.
604+
600605
The examples for this section use the following documents in a collection called
601606
``ingredients``:
602607

@@ -625,36 +630,35 @@ collection:
625630
public int Count { get; set; }
626631
}
627632

628-
.. note::
629-
630-
For all bitwise operators, if the operand list contains a missing or undefined
631-
value, the entire expression evaluates to ``null``.
633+
.. note:: Missing or Undefined Operands
632634

635+
If the operand list you pass to any bitwise operator contains a missing or
636+
undefined value, the entire expression evaluates to ``null``.
633637

634638
$bitAnd
635639
+++++++
636640

637-
The ``$bitAnd`` aggregation stage performs a bitwise AND operation on the given
638-
arguments. The following example shows how to generate a ``$bitAnd`` stage using
639-
LINQ:
641+
The ``$bitAnd`` aggregation operator performs a bitwise AND operation on the given
642+
arguments. You can use the ``$bitAnd`` operator by connecting two or more
643+
clauses with a ``&`` character. The following example shows how to create a
644+
``$bitAnd`` stage using LINQ:
640645

641646
.. code-block:: csharp
642647

643-
var query = queryableCollection.AsQueryable()
648+
var query = queryableCollection
644649
.Where(i => i.Name == "eggs")
645650
.Select(i => i.Price & i.Count);
646651

647-
The preceding example finds the document where the ``Name`` field has the value
648-
``"eggs"``. It then performs a bitwise AND operation on the values of the
649-
``Price`` and ``Count`` fields in this document. The result contains one value:
650-
``4``.
652+
The preceding example retrieves the document in which the ``Name`` field has the
653+
value ``"eggs"``. It then performs a bitwise AND operation on the values of the
654+
``Price`` and ``Count`` fields in this document, returning a value of ``4``.
651655

652656
The following example performs the same bitwise AND operation, but on all
653657
documents in the collection:
654658

655659
.. code-block:: csharp
656660

657-
var query = queryableCollection.AsQueryable()
661+
var query = queryableCollection
658662
.Select(i => i.Price & i.Count);
659663

660664
The result of the preceding example contains the following values:
@@ -675,30 +679,33 @@ the expression evaluates to ``null``.
675679
$bitOr
676680
++++++
677681

678-
The ``$bitOr`` aggregation stage performs a bitwise OR operation on the given
679-
arguments. The following example shows how to generate a ``$bitOr`` stage using
680-
LINQ:
682+
The ``$bitOr`` aggregation operator performs a bitwise OR operation on the given
683+
arguments. You can use the ``$bitOr`` operator by connecting two or more
684+
clauses with a ``|`` character. The following example shows how to create a
685+
``$bitOr`` stage using LINQ:
681686

682687
.. code-block:: csharp
683688

684-
var query = queryableCollection.AsQueryable()
689+
var query = queryableCollection
685690
.Where(i => i.Name == "eggs")
686691
.Select(i => i.Price | i.Count);
687692

688-
The preceding example finds the document where the ``Name`` field has the value
689-
``"eggs"``. It then performs a bitwise OR operation on the values of the
690-
``Price`` and ``Count`` fields in this document. The result contains one value:
693+
The preceding example retrieves the document in which the ``Name`` field has the
694+
value ``"eggs"``. It then performs a bitwise OR operation on the values of the
695+
``Price`` and ``Count`` fields in this document, returning the value
691696
``13``.
692697

693698
$bitNot
694699
+++++++
695700

696-
The ``$bitNot`` aggregation stage performs a bitwise NOT operation on the given
697-
argument. ``$bitNot`` only takes one argument.
701+
The ``$bitNot`` aggregation operator performs a bitwise NOT operation on the given
702+
argument. You can use the ``$bitNot`` operator by preceding an
703+
operand with a ``~`` character. ``$bitNot`` only takes one argument. The
704+
following example shows how to create a ``$bitNot`` stage using LINQ:
698705

699706
.. code-block:: csharp
700707

701-
var queryable = collection.AsQueryable()
708+
var queryable = collection
702709
.Select(i => ~i.Count);
703710

704711
The result of the preceding example contains the following values:
@@ -715,22 +722,21 @@ The result of the preceding example contains the following values:
715722
$bitXor
716723
+++++++
717724

718-
The ``$bitXor`` aggregation stage performs a bitwise XOR operation on the given
719-
arguments.
720-
721-
The following example shows how to generate a ``$bitXor`` stage using
722-
LINQ:
725+
The ``$bitXor`` aggregation operator performs a bitwise XOR operation on the given
726+
arguments. You can use the ``$bitXor`` operator by connecting two or more
727+
clauses with a ``^`` character. The following example shows how to create a
728+
``$bitXor`` stage using LINQ:
723729

724730
.. code-block:: csharp
725731

726-
var query = queryableCollection.AsQueryable()
732+
var query = queryableCollection
727733
.Where(i => i.Name == "eggs" || i.Name == "watermelon")
728734
.Select(i => i.Price ^ i.Count);
729735

730-
The preceding example finds the documents where the ``Name`` field has the value
731-
``"eggs"`` or ``"watermelon"``. It then performs a bitwise OR operation on the
732-
values of the ``Price`` and ``Count`` fields in these documents. The result
733-
contains the following values:
736+
The preceding example retrieves the documents in which the ``Name`` field has
737+
the value ``"eggs"`` or ``"watermelon"``. It then performs a bitwise XOR
738+
operation on the values of the ``Price`` and ``Count`` fields in these
739+
documents. The result contains the following values:
734740

735741
.. code-block:: json
736742

0 commit comments

Comments
 (0)