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

Empty _id using ReplaceOneAsync

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.0
    • None

    Description

      Hi,
      running that code :

      await this.Collection.ReplaceOneAsync(x => x.Name == city.Name x.CountryCode == city.CountryCode, newObject, new UpdateOptions()

      { IsUpsert = true }

      );

      if the object doesn't exist it create the new one but with an empty id.
      Here what is stored

      /* 1 */

      { "_id" : ObjectId("000000000000000000000000"), "CreateAt" : [ NumberLong(635700317931446025), 0 ], "UpdateAt" : [ NumberLong(635700317931446025), 0 ], "Name" : "My value", "CountryCode" : "it", "Culture" : "en-US" }

      Attachments

        Activity

          People

            Unassigned Unassigned
            imperugo Ugo Lattanzi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: