Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. var projection = Builders<BsonDocument>.Projection.Include("title");
  2.  
  3. db.books.aggregate(
  4. [
  5. {
  6. $project: {
  7. title: 1,
  8. lastName: "$author.lastName",
  9. }
  10. }
  11. ]
  12. )
  13.  
  14. var project = new BsonDocument
  15. {
  16. {
  17. "$project",
  18. new BsonDocument
  19. {
  20. {"title", 1},
  21. {"lastName", "$author.lastName"},
  22. }
  23. }
  24. };
  25.  
  26. var pipelineLast = new[] { project };
  27.  
  28.  
  29. var resultLast = db.books.Aggregate<BsonDocument>(pipelineLast);
  30. var matchingExamples = await resultLast.ToListAsync();
  31. foreach (var example in matchingExamples)
  32. {
  33. // Display the result
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement