I am in a situation where I can't predict which fields my MongoDB document is going to have. So I can no longer create an object with an _id field of type BsonID.
I find it very convenient to create a Dictionary (HashTable) and add my DateTime and String objects inside, as many times as I need it.
I then try to insert the resulting Dictionary object into MongoDb, but default serialization fails.
Here's my object of Type HashTable (like a Dictionary, but with varied types inside):
{ "_id":"",
"metadata1":"asaad",
"metadata2":[],
"metadata3":ISODate("somedatehere")}
And the error from the driver I get is:
Serializer DictionarySerializer expected serialization options of type DictionarySerializationOptions, not DocumentSerializationOptions
I googled it, but couldn't find anything useful. What am I doing wrong?