I want to retrieve the list of Booking collection.
Some of the collection have,
Case 1
"Countries": [{
"Destinations": [{
"Code": "CHX",
"Name": "French Alps"
}],
"Code": {
"_t": "JsonElement"
},
"Name": {
"_t": "JsonElement"
}
}]
and some of them have,
Case 2
"Countries": [{
"Destinations": [{
"Code": "DXB",
"Name": "Dubai"
}],
"Code": "AE",
"Name": "United Arab Emirates"
}]
Note that code
and name
fields.
and the model for retrieve list is
{
public List<DestinationDocument> Destinations { get; set; } = new List<DestinationDocument>();
public string Code { get; set; }
public string Name { get; set; }
}
I want to to ignore the code
and name
when they are not string (i.e I want to ignore code
and name
of case 1 . but not Destinations
of case 1 ).
How can I do that using mongoDb driver.
I tried SetIgnoreExtraElements
. but it does not work.