I have set the SetIdMember()
for a class map to point to an element within the object:
BsonClassMap.RegisterClassMap<Person>(x =>
{
x.AutoMap();
x.SetIdMember(x.GetMemberMap(p => p.PersistedId));
});
Which works fine, however I was looking in the mongo data (via MongoVUE) and noticed that the PersistedId field is not stored anywhere in the database, I presume this is because it maps it to the _id field.
Now for 99% of scenarios im sure that is fine, however in this case I am using a non-strongly typed model, and pulling back a raw BsonDocument, then turning it to JSON for handing to a clientside script to then use further. However it is expecting to get a PersistedId field in the JSON but it doesn't exist, it is just _id.
So is there a way for me to get it to do its whole unique _id field thing, but also get it to write out the PersistedId field to the database too? (I know its going to be duplicated data, but its not a major worry)