Skip to content

Commit 9336b6d

Browse files
committed
CR Changes
1 parent 69639c6 commit 9336b6d

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

Docs/reference/content/reference/driver/crud/reading.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ var result = await collection.Find(filter)
106106

107107
## Aggregation
108108

109-
MongoDB offers the [aggregation framework]({{< docsref "core/aggregation-pipeline/" >}}) which can be accessed via the [`Aggregate`]({{< apiref "M_MongoDB_Driver_IMongoCollectionExtensions_Aggregate__1" >}}) method. The result type is [`IAggregateFluent`]({{< apiref "T_MongoDB_Driver_IAggregateFluent_1" >}}) and provides access to build up and aggregation pipeline.
109+
MongoDB offers the [aggregation framework]({{< docsref "core/aggregation-pipeline/" >}}) which can be accessed via the [`Aggregate`]({{< apiref "M_MongoDB_Driver_IMongoCollectionExtensions_Aggregate__1" >}}) method. The result type is [`IAggregateFluent`]({{< apiref "T_MongoDB_Driver_IAggregateFluent_1" >}}) and provides access to a fluent API to build up an aggregation pipeline.
110110

111111
The first example from [MongoDB's documentation]({{< docsref "tutorial/aggregation-zip-code-data-set/#return-states-with-populations-above-10-million" >}}) is done in a type-safe manner below:
112112

@@ -127,9 +127,10 @@ class ZipEntry
127127
public int Population { get; set; }
128128
}
129129

130-
var pipeline = db.GetCollection<ZipEntry>.Aggregate()
130+
var results = await db.GetCollection<ZipEntry>.Aggregate()
131131
.Group(x => x.State, g => new { State = g.Key, TotalPopulation = g.Sum(x => x.Population) })
132-
.Match(x => x.TotalPopulation > 20000);
132+
.Match(x => x.TotalPopulation > 20000)
133+
.ToListAsync();
133134
```
134135

135136
This will result in the following aggregation pipeline getting sent to the server:
@@ -147,11 +148,11 @@ More samples are located in the [source]({{< srcref "MongoDB.Driver.Tests/Sample
147148

148149
All the [stage operators]({{< docsref "reference/operator/aggregation/#aggregation-pipeline-operator-reference" >}}) are supported, however some of them must use the [`AppendStage`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_AppendStage__1" >}}) method due to lack of support for certain projections in the language.
149150

150-
{{% note class="important" %}}Unlike `Find`, the order that stages are defined in matters. `Skip(10).Limit(10)` is not the same as `Limit(10).Skip(10)`.{{% /note %}}
151+
{{% note class="important" %}}Unlike `Find`, the order that stages are defined in matters. `Skip(10).Limit(20)` is not the same as `Limit(20).Skip(10)`.{{% /note %}}
151152

152153
#### $project
153154

154-
A `$project` is rendered using the [`Project`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Project__1" >}}) method and its overloads. Unlike in `Find`, an aggregate projection is not executed client-side and must be fully translatable to the server's supported expressions. See [expressions]({{< relref "reference\driver\expressions.md#projections" >}}) for more detail about the expressions available inside a $project.
155+
A `$project` is defined using the [`Project`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Project__1" >}}) method and its overloads. Unlike in `Find`, an aggregate projection is not executed client-side and must be fully translatable to the server's supported expressions. See [expressions]({{< relref "reference\driver\expressions.md#projections" >}}) for more detail about the expressions available inside a $project.
155156

156157
```csharp
157158
Project(x => new { Name = x.FirstName + " " + x.LastName });
@@ -164,7 +165,7 @@ Project(x => new { Name = x.FirstName + " " + x.LastName });
164165

165166
#### $match
166167

167-
A `$match` stage is rendered using the [`Match`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Match" >}}) method and its overloads. It follows the same requirements as that of `Find`.
168+
A `$match` stage is defined using the [`Match`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Match" >}}) method and its overloads. It follows the same requirements as that of `Find`.
168169

169170
```csharp
170171
Match(x => x.Age > 21);
@@ -179,7 +180,7 @@ There is no method defined for a `$redact` stage. However, it can be added using
179180

180181
#### $limit
181182

182-
A `$limit` stage is rendered using the [`Limit`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Limit" >}}) method.
183+
A `$limit` stage is defined using the [`Limit`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Limit" >}}) method.
183184

184185
```csharp
185186
Limit(20);
@@ -190,7 +191,7 @@ Limit(20);
190191

191192
#### $skip
192193

193-
A `$skip` stage is rendered using the [`Skip`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Skip" >}}) method.
194+
A `$skip` stage is defined using the [`Skip`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Skip" >}}) method.
194195

195196
```csharp
196197
Skip(20);
@@ -201,7 +202,7 @@ Skip(20);
201202

202203
#### $unwind
203204

204-
An `$unwind` stage is rendered using the [`Unwind`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Unwind__1" >}}) method and its overloads. Because $unwind is a type of projection, you must provide a return type, although not specifying one will use the overload that projects into a [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}).
205+
An `$unwind` stage is defined using the [`Unwind`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Unwind__1" >}}) method and its overloads. Because $unwind is a type of projection, you must provide a return type, although not specifying one will use the overload that projects into a [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}).
205206

206207
```csharp
207208
Unwind(x => x.ArrayFieldToUnwind);
@@ -212,7 +213,7 @@ Unwind(x => x.ArrayFieldToUnwind);
212213

213214
#### $group
214215

215-
A `$group` stage is rendered using the [`Group`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Group__1" >}}) method and its overloads. Because $unwind is a type of projection, you must provide a return type. The most useful of the overloads is where 2 lambda expressions are expressed, the first for the key and the second for the grouping. See [expressions]({{< relref "reference\driver\expressions.md#grouping" >}}) for more detail about the expressions available inside a $group.
216+
A `$group` stage is defined using the [`Group`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Group__1" >}}) method and its overloads. Because $unwind is a type of projection, you must provide a return type. The most useful of the overloads is where two lambda expressions are expressed, the first for the key and the second for the grouping. See [expressions]({{< relref "reference\driver\expressions.md#grouping" >}}) for more detail about the expressions available inside a $group.
216217

217218
```csharp
218219
Group(x => x.Name, g => new { Name = g.Key, AverageAge = g.Average(x = x.Age) });
@@ -225,7 +226,7 @@ As in project, it is required that the result of the grouping be a new type, eit
225226

226227
#### $sort
227228

228-
A `$sort` stage is rendered using the [`Sort`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Sort" >}}) method. However, `SortBy`, `SortByDescending`, `ThenBy`, and `ThenByDescending` are also present.
229+
A `$sort` stage is defined using the [`Sort`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Sort" >}}) method. However, `SortBy`, `SortByDescending`, `ThenBy`, and `ThenByDescending` are also available.
229230

230231
```csharp
231232
SortBy(x => x.LastName).ThenByDescending(x => x.Age);
@@ -240,10 +241,10 @@ There is no method defined for a `$geoNear` stage. However, it can be added usin
240241

241242
#### $out
242243

243-
A `$out` stage is rendered using the [`Out`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_Out" >}}) method.
244+
A `$out` stage is defined using the [`OutAsync`]({{< apiref "M_MongoDB_Driver_IAggregateFluent_1_OutAsync" >}}) method. It must be the final stage and it triggers execution of the operation.
244245

245246
```csharp
246-
Out("myNewCollection");
247+
OutAsync("myNewCollection");
247248
```
248249
```json
249250
{ $out: 'myNewCollection' }

Docs/reference/content/reference/driver/crud/writing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var result = await collection.FindOneAndDeleteAsync(filter);
104104

105105
if (result != null)
106106
{
107-
Assert(result["FirstName"] == "Jack");
107+
Assert(result["FirstName"] == "Jack");
108108
}
109109
```
110110

@@ -170,7 +170,7 @@ var result = await collection.FindOneAndUpdateAsync(filter, update, options);
170170

171171
if (result != null)
172172
{
173-
Assert(result["FirstName"] == "John");
173+
Assert(result["FirstName"] == "John");
174174
}
175175
```
176176

Docs/reference/content/reference/driver/expressions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Find(x => x.FavoriteNumbers.Count() == 3);
302302
{ FavoriteNumbers: { $size: 3 } }
303303
```
304304

305-
## Aggregate
305+
## Aggregation Projections
306306

307307
We'll walk through the supported expressions below. The [tests]({{< srcref "MongoDB.Driver.Tests/Linq/Translators/AggregateProjectionTranslatorTests_Project.cs" >}}) are also a good reference.
308308

@@ -799,11 +799,11 @@ p => p.Name ?? "awesome";
799799

800800
See the [MongoDB documentation]({{< docsref "meta/aggregation-quick-reference/#accumulators" >}}) for more information on each operator.
801801

802-
Also, the [tests]({{< srcref "MongoDB.Driver.Tests/Linq/Translators/AggregateProjectionTranslatorTests_Group.cs" >}}) are also a good reference.
802+
Also, the [tests]({{< srcref "MongoDB.Driver.Tests/Linq/Translators/AggregateProjectionTranslatorTests_Group.cs" >}}) are a good reference.
803803

804804
{{% note %}}These are only supported in a grouping expression.{{% /note %}}
805805

806-
In the below, it should be assumed that `g` is of type [`IGrouping<TKey, TElement>`]({{< msdnref "bb344977" >}}).
806+
In the examples below, it should be assumed that `g` is of type [`IGrouping<TKey, TElement>`]({{< msdnref "bb344977" >}}).
807807

808808
#### $sum
809809

0 commit comments

Comments
 (0)