I want to use the positional operator of the MongoDB in C# code. Here is data structure for Customer:
{
name:"Robert",
age:40,
addresses:[
{street:"...", city:"New York", country:"USA", ...},
{street:"...", city:"California", country:"USA", ...},
],
}
So, if I want to update the street value where the address if of New York city, I use this query in MongoDB:
db.customer.update(
{ "addresses.city" : "New York"},
{ $set : {
"addresses.$" : {"street":"New street", city:"New York", country:"USA",...}
} }, false, true);
What is the equivalent query to use in C# code? How to use the positional operator in C# code?
I'm using the official MongoDB driver.