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

Atomic update (Set) not work if object value null

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:

      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

            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: