The ID field on an object is supposed to be populated after an Insert; however this does not work when the id field is private.
In particular, the following unit test fails:
public class PrivateIdField { [BsonId] private ObjectId _id; public ObjectId Id { get { return _id; } } } [Test] public void TestPrivateIdPopulation() { var privateIdField = new PrivateIdField(); _collection.Insert(privateIdField); Assert.AreNotEqual(privateIdField.Id, default(ObjectId)); }
I saw this example in Robert's stack overflow answer here.
- depends on
-
CSHARP-584 Improve the design of the convention system for automapping BsonClassMaps
- Closed