Distinguish between null and missing field when mapping (POCO) with mongodb
Clash 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.