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

Unable to cast object of type 'MongoDB.Bson.BsonArray' to type 'MongoDB.Bson.BsonDocument'

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Gone away
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None
    • 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?

    Description

      This code

      new PipelineUpdateDefinition<MyDocument>(
          new EmptyPipelineDefinition<MyDocument>()
              .Match(a => a.MyObject == null))
                  .Set(a => a.MyObject, new MyDocument.MyObject())
                  .Render(
                      BsonSerializer.SerializerRegistry.GetSerializer<MyDocument>(),
                      BsonSerializer.SerializerRegistry
                  ).ToBsonDocument();
      

      Gives me this error:

      System.InvalidCastException:
      Unable to cast object of type 'MongoDB.Bson.BsonArray' to type 'MongoDB.Bson.BsonDocument'.
      

      I think it is a bug.

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            rizwaanb10@gmail.com A B
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: