Generate ObjectId to wrong property when BsonId property is in the parent class

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Moved from: http://github.com/mongodb/mongo-csharp-driver/issues#issue/5

      Hi,

      I think this is not the correct result. Please see the following code:

      public class BaseModel
      { [BsonId] public ObjectId Id

      { get; set; } }

      public class User : BaseModel
      { public ObjectId FriendId { get; set; }

      }

      [TestFixture] public class Test
      { [Test] public void New()

      { ... // create collections var model = new User(); collection.Save(model); }

      }

      The result in mongodb is:

      db.user.find()

      { "FriendId" : ObjectId("xxxxxxxxxxxxxxxxxxxxxxx"), "_id" : ObjectId("0000000000000000000") }

      [I modified above code from my real code so the result might not be the same order but the point is in my result, new object id is assigned to wrong property]

            Assignee:
            Robert Stam (Inactive)
            Reporter:
            Robert Stam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: