mongodb - MongDb C# Driver is deserialzing null values for a List member as empty -


i'm using mongodb c# driver in 1 of applications. have defined entity below , defined classmaps enforce schema.

public class testentity {     public string id { get; set; }     public string name { get; set; }     public string description { get; set; }     public list<somemodel> properties { get; set; } } 

also, i've defined conventions disable serialization of empty or null arrays/lists.

new conventionpack { new ignoreifnullconvention(true) conventionpack.add(new ignoreemptyarraysconvention()); 

everything works expected, when query document using c# driver below, properties empty list instead of null.

database.getcollection<testentity>("test").find(filter, findoptions).firstordefault() 

for example, if have testentity document follows, when query using c# driver "properties" property returned empty list instead of null.

{ "_id":objectid("5991be3475f14655406cd301"), "name": "test", "description": "test" }

i couldn't find answer when searched online. hope can help. thanks

remove convention ignoreemptyarraysconvention looking @ code here seems creates new instance of list.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -