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

Atomic update (Set) not work if object value null

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 1.4
    • 1.3
    • None

    Description

      Example:

      var message = new SomeClassWithFieldCode();
      //if code is null it will not update field, need to use BsonNull.Value in case if object value null
      var update = Update.Set("Code", message.Code); // Code is null
      mongoCollection.Update(Query.EQ("_id", message.Id), update);

      I suppose driver should replace null with BsonNull.Value internally rather than set it manually on each update in case if some property value equals to null.

      Thank you.

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            anorsich Andrew Orsich
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: