MongoDB.Bson.BsonSerializationException (when serializing List of MongoDBRef)

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 2.22.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Using MongoDB Driver version 2.19

      The error (MongoDB.Bson.BsonSerializationException: 'An error occurred while serializing the students property of class PatientJourney.ExamModel: Element name '$ref' is not valid'.') is thrown when calling the method _collection.ReplaceOneAsync(filter,model) with students.length >1 which dataType is List<MongoDBRef>.

      The error is not thrown when using the method _collection.InsertOneAsync(model) and when the length of the MongoDBRef List is not larger than 1 in the _collection.ReplaceOneAsync(filter,model) method. Note that the same model is passed to InsertOneAsync method and ReplaceOneAsync method

            Assignee:
            Oleksandr Poliakov
            Reporter:
            Lok Fung Leung
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: