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

First and Last accumulators should thrown an exception when used with a predicate.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.0.1, 2.1
    • Affects Version/s: 2.0
    • Component/s: Linq
    • Labels:
      None

      Since MongoDB doesn't support predicates inside the $first and $last operators, we should throw a not supported exception.

      
      var list = await collection.Aggregate()
          .Group(x => x.Name, g => new { Key = g.Key, FavoritePet = g.Pets.First(x => x.Name == "Fluffy") })
          .ToListAsync();
      
      

      Currently, I believe the predicates are getting dropped when we rewrite First/Last calls

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

              Created:
              Updated:
              Resolved: