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

Unexpected field in deserialization for projection expression with a positional operator

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 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.

            Assignee:
            mikalai.mazurenka@mongodb.com Mikalai Mazurenka (Inactive)
            Reporter:
            wegylexy@gmail.com TimTIM Wong
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: