Google Groups

Using default constructor when deserializing


Bas Geertsema May 7, 2012 4:12 AM
Posted in group: mongodb-user
I recently upgraded my C# mongodb driver to the latest release. My
previous version was a couple of months old. It seems that with the
latest release the default (no parameters) constructors are no longer
called upon deserialization. Is this correct?

I used to set default values in the constructor, however in the latest
release these fields are null after deserialization. I.e. when a
property is present in the object but not in the fetched bson document
it is set to null rather than having the value set in the constructor.

I have trouble finding out when or how this has changed. And whether I
can overrule this behaviour somehow. Can someone shed a light on this?

Thanks,

Bas