I want to conditionally exclude a field from the projection. Below is my document and I want to execlude projection of Professors if the class type is English.
My document:
{
"Name": "HumanName",
"Occupation": "Student",
"Class": [
{
"ClassType": "Math",
"Professors": [
{
"Name": "Jimmy"
},
{
"Name": "Smith"
}
]
},
{
"ClassType": "English",
"Professors": [
{
"Name": "John"
}
]
}
]
}
Exprected result:
{
"Name": "HumanName",
"Occupation": "Student",
"Class": [
{
"ClassType": "Math",
"Professors": [
{
"Name": "Jimmy"
},
{
"Name": "Smith"
}
]
},
{
"ClassType": "English",
"Professors": []
}
]
}
Can we achieve this using C# driver and if we can please share a example.