|
| 1 | +.. _csharp-aggregation: |
| 2 | + |
| 3 | +====================== |
| 4 | +Aggregation Operations |
| 5 | +====================== |
| 6 | + |
| 7 | +.. facet:: |
| 8 | + :name: genre |
| 9 | + :values: reference |
| 10 | + |
| 11 | +.. meta:: |
| 12 | + :keywords: dotnet, code example, transform, pipeline |
| 13 | + |
| 14 | +.. contents:: On this page |
| 15 | + :local: |
| 16 | + :backlinks: none |
| 17 | + :depth: 2 |
| 18 | + :class: singlecol |
| 19 | + |
| 20 | +.. toctree:: |
| 21 | + :titlesonly: |
| 22 | + :maxdepth: 1 |
| 23 | + |
| 24 | + Pipeline Stages </aggregation/stages> |
| 25 | + LINQ </aggregation/linq> |
| 26 | + |
| 27 | +Overview |
| 28 | +-------- |
| 29 | + |
| 30 | +In this guide, you can learn how to use the {+driver-long+} to perform |
| 31 | +**aggregation operations**. |
| 32 | + |
| 33 | +Aggregation operations process data in your MongoDB collections and |
| 34 | +return computed results. The MongoDB Aggregation framework is modeled on the |
| 35 | +concept of data processing pipelines. Documents enter a pipeline comprised of one or |
| 36 | +more stages, and this pipeline transforms the documents into an aggregated result. |
| 37 | + |
| 38 | +To learn more about the aggregation stages supported by the {+driver-short+}, see |
| 39 | +:ref:`Aggregation Stages <csharp-aggregation-stages>`. |
| 40 | + |
| 41 | +.. sharedinclude:: dbx/agg-tutorials-manual-tip.rst |
| 42 | + |
| 43 | + .. replacement:: language |
| 44 | + |
| 45 | + :guilabel:`{+language+}` |
| 46 | + |
| 47 | +Analogy |
| 48 | +~~~~~~~ |
| 49 | + |
| 50 | +Aggregation operations function similarly to car factories with assembly |
| 51 | +lines. The assembly lines have stations with specialized tools to |
| 52 | +perform specific tasks. For example, when building a car, the assembly |
| 53 | +line begins with the frame. Then, as the car frame moves through the |
| 54 | +assembly line, each station assembles a separate part. The result is a |
| 55 | +transformed final product, the finished car. |
| 56 | + |
| 57 | +The assembly line represents the *aggregation pipeline*, the individual |
| 58 | +stations represent the *aggregation stages*, the specialized tools |
| 59 | +represent the *expression operators*, and the finished product |
| 60 | +represents the *aggregated result*. |
| 61 | + |
| 62 | +Compare Aggregation and Find Operations |
| 63 | +--------------------------------------- |
| 64 | + |
| 65 | +The following table lists the different tasks you can perform with find |
| 66 | +operations, compared to what you can achieve with aggregation |
| 67 | +operations. The aggregation framework provides expanded functionality |
| 68 | +that allows you to transform and manipulate your data. |
| 69 | + |
| 70 | +.. list-table:: |
| 71 | + :header-rows: 1 |
| 72 | + :widths: 50 50 |
| 73 | + |
| 74 | + * - Find Operations |
| 75 | + - Aggregation Operations |
| 76 | + |
| 77 | + * - | Select *certain* documents to return |
| 78 | + | Select *which* fields to return |
| 79 | + | Sort the results |
| 80 | + | Limit the results |
| 81 | + | Count the results |
| 82 | + - | Select *certain* documents to return |
| 83 | + | Select *which* fields to return |
| 84 | + | Sort the results |
| 85 | + | Limit the results |
| 86 | + | Count the results |
| 87 | + | Group the results |
| 88 | + | Rename fields |
| 89 | + | Compute new fields |
| 90 | + | Summarize data |
| 91 | + | Connect and merge data sets |
| 92 | + |
| 93 | +Server Limitations |
| 94 | +------------------ |
| 95 | + |
| 96 | +Consider the following :manual:`limitations </core/aggregation-pipeline-limits/>` when |
| 97 | +performing aggregation operations: |
| 98 | + |
| 99 | +- Returned documents must not violate the :manual:`BSON document size limit </reference/limits/#mongodb-limit-BSON-Document-Size>` |
| 100 | + of 16 megabytes. |
| 101 | + |
| 102 | +- Pipeline stages have a memory limit of 100 megabytes by default. If required, you can exceed this limit by setting |
| 103 | + the `AllowDiskUse <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.AggregateOptions.AllowDiskUse.html#MongoDB_Driver_AggregateOptions_AllowDiskUse>`__ |
| 104 | + property of the ``AggregateOptions`` object that you pass to the ``Aggregate()`` method. |
| 105 | + |
| 106 | +Troubleshooting |
| 107 | +--------------- |
| 108 | + |
| 109 | +.. include:: /includes/troubleshooting/unsupported-filter-expression.rst |
| 110 | + |
| 111 | +Additional Information |
| 112 | +---------------------- |
| 113 | + |
| 114 | +To view a full list of expression operators, see |
| 115 | +:manual:`Aggregation Operators </reference/operator/aggregation/>`. |
| 116 | + |
| 117 | +To learn about explaining MongoDB aggregation operations, see |
| 118 | +:manual:`Explain Results </reference/explain-results/>` and |
| 119 | +:manual:`Query Plans </core/query-plans/>`. |
0 commit comments