[CSHARP-1234] Using Dollar Projection operator works with expression trees but not with builders. Created: 07/Apr/15  Updated: 27/Apr/15  Resolved: 27/Apr/15

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 2.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Craig Wilson Assignee: Craig Wilson
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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();


Generated at Wed Feb 07 21:39:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.