SHARE
TWEET

Untitled

a guest Jul 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top