Skip to content

Commit ffba577

Browse files
committed
Add C# example to challenge in order-limit.mdx
1 parent 1c27d20 commit ffba577

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/40-CRUD/3-ORDER-LIMIT.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,18 @@ This returns the **top 10 available books** in the "Science Fiction" genre.
8686
```
8787
</div>
8888
</TabItem>
89+
<TabItem value="csharp" label="C#">
90+
<div>
91+
```csharp
92+
var projection = Builders<Book>.Projection.Include(b => b.Title).Include(b => b.Pages);
93+
var descendingPagesSort = Builders<Book>.Sort.Ascending("title");
94+
95+
List<Book> sortedBooksLimitedToTen = booksCollection.Find(b => true) // Empty filter to find all books
96+
.Project<Book>(projection)
97+
.Sort(descendingPagesSort)
98+
.Limit(10).ToList();
99+
```
100+
</div>
101+
</TabItem>
89102
</Tabs>
90103
</details>

0 commit comments

Comments
 (0)