-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.10.4
-
Component/s: Linq, Serialization
-
None
var find = collection.Find(x => x.ArrayField.Any(predicate)); var a = find.Project<TypeOfX>( Builders<TypeOfX>.Projection .Include(x => x.ArrayField[-1]) .Exclude(x => x.Id) ) .FirstOrDefault() // <-- OK ?.ArrayField[0]; var b = find.Project(x => x.ArrayField[-1]) .FirstOrDefault(); // <-- MongoInternalException: Unexpected field
Both a and b should be the same, but b throws an exception.
If FirstOrDefault() is replaced with ToString(), both queries are exactly the same. There is a bug in the projection object deserializer.