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

LinqV3 Projection ObjectId deserialization error

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.19.0
    • Affects Version/s: 2.15.1, 2.17.1
    • Component/s: LINQ3
    • None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      LinqProvider V3 failed to materialize a C# projection object (defined class, not an anomymous class) from a C# source object with an ObjectId string serializer : An error occurred while deserializing the Id property of class ConsoleApp.Projections.IdObjectBase: Cannot deserialize a 'String' from BsonType 'ObjectId'.

      Tested with MongoDb driver 2.17.1 and 2.15.1 over local MongoDb instance.

      How to Reproduce

      See C# .Net6 attached project that reproduces the error.

      Additional Background

      ObjectId deserialization is working as expected when using LinqProvider.V2.

      I really think that deserialization MUST use the C# source object serialization configuration over the projection.

      Please note that it is working fine (and as expected) when using an anomyous object for projection with LinqProvider.V3.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            laurent.jeancler@assurware.com Laurent Jeancler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: