[CSHARP-1579] SetIdMember call being ignored. Created: 25/Feb/16  Updated: 26/Feb/16  Resolved: 26/Feb/16

Status: Closed
Project: C# Driver
Component/s: BSON, Serialization
Affects Version/s: 2.2.3
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: William Eidson Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I have code that used to work and has stopped. The code defines a member of a base class as the "ID" via the usual pattern.

BsonClassMap.RegisterClassMap<Message>(cm =>

{ cm.AutoMap(); cm.SetIdMember(cm.GetMemberMap(c => c.UniqueId)); }

);

where UniqueID is a GUID.

I Dropped the collection containing this type ( and its decendents) and reinstered an instance of a derived class.

The database after the insert has an _id with an ObjectId in it !! A subsequent deserialize fails trying to make objectid into guid.

Any thoughts on what I could have done to break this.



 Comments   
Comment by Craig Wilson [ 26/Feb/16 ]

Thanks for the update William.

Comment by William Eidson [ 26/Feb/16 ]

Ok, this is a big never mind. The BsonClassMapping is done in a static ctor. Someone removed the inital call to a static on that class which prevented the ctor from ever running!

Comment by William Eidson [ 25/Feb/16 ]

additionally the db contains both an _id field and the UniqueID field within the _t of the object

Generated at Wed Feb 07 21:40:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.