AnyOne
AnyOne

Reputation: 931

Dealing nullable properties in MongoDb driver

I am using 10Gen .net driver for MongoDB and querying objects that has empty collection properties comes as null. So i tried to set collections in constructor of object but after deserilization it is again null.

Is there any settings that driver will set collection properties as empty collection instead of null ?

Upvotes: 1

Views: 850

Answers (1)

Robert Stam
Robert Stam

Reputation: 12187

I don't understand exactly what you mean. Can you provide a sample class declaration and the resulting document when it is serialized?

If the collection property was null when you serialized it then it will be null when you deserialize it. If the collection property is an empty collection when you serialized then it will also be an empty collection when you deserialize it. You should always get back exactly what it had when you serialized it.

Upvotes: 2

Related Questions