@@ -323,10 +323,9 @@ following documents:
323
323
Nested Statements
324
324
+++++++++++++++++
325
325
326
- You can chain or nest ``Select`` and ``SelectMany`` statements. The examples
327
- in this section use the ``Guidebook`` class, which contain an array of ``Restaurant``
328
- objects. The following code shows an example of a document modeled by the
329
- ``Guidebook`` class:
326
+ You can chain or nest ``Select`` and ``SelectMany`` statements to unwind nested
327
+ arrays. Consider a collection that holds documents with a ``restaurants`` field.
328
+ This field contains an array of documents that represent the ``Restaurants`` class:
330
329
331
330
.. code-block:: json
332
331
@@ -337,29 +336,36 @@ objects. The following code shows an example of a document modeled by the
337
336
"_id": { ... } ,
338
337
"address": { ... },
339
338
"name": "Tov Kosher Kitchen",
339
+ "grades": [
340
+ {
341
+ "date" : ISODate("2014-11-24T00:00:00Z"),
342
+ "grade" : "Z",
343
+ "score" : 20.0
344
+ },
345
+ {
346
+ "date" : ISODate("2013-01-17T00:00:00Z"),
347
+ "grade" : "A",
348
+ "score" : 13.0
349
+ },
350
+ ...
351
+ ]
340
352
...
341
353
},
342
354
{
343
355
"_id": { ... } ,
344
356
"address": { ... },
345
357
"name": "Harriet's Kitchen",
358
+ "grades": [ ... ],
346
359
...
347
360
},
348
361
...
349
362
]
350
363
}
351
364
352
- The following code models the ``Guidebook`` class:
353
-
354
- .. literalinclude:: /includes/fundamentals/code-examples/linq.cs
355
- :language: csharp
356
- :start-after: start-guidebook-model
357
- :end-before: end-guidebook-model
358
-
359
365
You can nest ``SelectMany`` statements within ``SelectMany`` or ``Select``
360
366
statements. The following example nests a ``SelectMany`` statement within a
361
- ``Select`` statement to retrieve an array of grades from all restaurants
362
- in a document modeled by the ``Guidebook`` class .
367
+ ``Select`` statement to retrieve an array of ``Grade`` documents from all restaurants
368
+ in the document above .
363
369
364
370
.. io-code-block::
365
371
:copyable: true
0 commit comments