Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1234

Using Dollar Projection operator works with expression trees but not with builders.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • None
    • 2.0
    • None
    • None

    Description

      Using below 2 queries generate the same projection, but the results are different:

      // works
      collection.Find(x => x.Pets.Any(p => p.Name == "Jack")
          .Project(x => x.Pets.ElementAt(-1))
          .ToListAsync();
       
      // doesn't work
      collection.Find(x => x.Pets.Any(p => p.Name == "Jack")
          .Project(Builders<Person>.Projection.Include(p => p.Pets.ElementAt(-1)))
          .ToListAsync();
      

      Attachments

        Activity

          People

            craig.wilson@mongodb.com Craig Wilson
            craig.wilson@mongodb.com Craig Wilson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: