Distinguish between null and missing field when mapping (POCO) with mongodb

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Distinguish between null and missing field when mapping (POCO) with mongodb



Lets say i have a class


class Person

[BsonElement("name")]
public string Name get; set;

[BsonElement("age")]
public int? Age get; set;



then in mongo I have



[
"name": "Jan",
"age": null
,
"name": "San",
"age": 20
,
"age": 20
]



Then call


collection.Find(filter).Project<Person>(projections).ToListAsync()



and then I get back



[
"Name": "Jan",
"Age": null
,
"Name": "San",
"Age": 20
,
"Name": null,
"Age": 20
]



Is there a way to see if the field was missing and not just get null back









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

0Rk3ImqZMuOS5whiv0tdfZoEP O36o zZgnaS,yiBozeC0j,Gg 9,I f6t2gY7ayzw9mrbGWL4Qx TqnK0R8mtpi0O,A9c,Zbo
uHO1zpNJ6rmG6K,y

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3