[CSHARP-1257] First and Last accumulators should thrown an exception when used with a predicate. Created: 27/Apr/15  Updated: 16/Jul/15  Resolved: 01/May/15

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.0
Fix Version/s: 2.0.1, 2.1

Type: Bug Priority: Minor - P4
Reporter: Craig Wilson Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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



 Comments   
Comment by Craig Wilson [ 01/May/15 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP1257: First and Last rewriting was ignoring the predicate argument.
Branch: v2.0.x
https://github.com/mongodb/mongo-csharp-driver/commit/568398cca39535aa4290206866e5936f6009ea4b

Comment by Githook User [ 01/May/15 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1257: First and Last rewriting was ignoring the predicate argument.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/511090168f527961f26a807e24c7cd83e0af4d07

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