Skip to content

Commit 6c4d5b9

Browse files
committed
Switched to sync for consistency. Added clarifying comment. Added limit to reduce time spent processing in-memory. Updates triggered by review
1 parent 4c07be9 commit 6c4d5b9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

dotnet/100_aggregation_pipeline_match.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
},
218218
"outputs": [],
219219
"source": [
220+
"// _id is included by default so unlike other fields, you don't need to explicitly include it here.\n",
220221
"var showTitleAndYear = Builders<Book>.Projection.Include(b => b.Title)\n",
221222
".Include(b => b.Year);\n",
222223
"\n",
@@ -270,7 +271,7 @@
270271
" .Match(matchStage)\n",
271272
" .Project<Book>(projection);\n",
272273
"\n",
273-
"List<Book> booksFrom2010Projected = await pipeline.ToListAsync();\n",
274+
"List<Book> booksFrom2010Projected = pipeline.ToList();\n",
274275
"\n",
275276
"if(booksFrom2010Projected != null)\n",
276277
"{\n",

dotnet/20_project_sort_limit.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"\n",
9898
"List<Book> sortedBooks = booksCollection.Find(b => true) // Empty filter to find all books\n",
9999
".Project<Book>(projection)\n",
100+
".Limit(50)\n",
100101
".Sort(descendingPagesSort).ToList();\n",
101102
"\n",
102103
"if(sortedBooks != null)\n",
@@ -147,7 +148,7 @@
147148
"{\n",
148149
" foreach(var book in sortedBooksLimitedToTen)\n",
149150
" {\n",
150-
" Console.WriteLine($\"Book Title: {book.Title} - Pages: {book.Pages}\");\n",
151+
" Console.WriteLine($\"Book Title: {book.Title} - Pages: {book.Pages}\");\n",
151152
" }\n",
152153
"}\n",
153154
"else \n",
@@ -191,7 +192,7 @@
191192
"{\n",
192193
" foreach(var book in sortedBooksLimitedToTenSkipFour)\n",
193194
" {\n",
194-
" Console.WriteLine($\"Book Title: {book.Title} - Pages: {book.Pages}\");\n",
195+
" Console.WriteLine($\"Book Title: {book.Title} - Pages: {book.Pages}\");\n",
195196
" }\n",
196197
"}\n",
197198
"else \n",

0 commit comments

Comments
 (0)