Pacman Pacman - 1 month ago 10
C# Question

query array using mongo for C#

I have the following json

{
"_id" : ObjectId("4f7ee46e08403d063ab0b4f9"),
"name" : "MongoDB",
"notes" : [
{
"title" : "Hello MongoDB",
"content" : "Hello MongoDB"
},
{
"title" : "ReplicaSet MongoDB",
"content" : "ReplicaSet MongoDB"
}
]
}


I am able to query a specific document in this manner:

db.collection.find({ "notes.title" : "Hello MongoDB"});


How do I go about creating the above query using FilterDefinition?
I am using Mongo for C#

Answer
var filter = Builders<BsonDocument>.Filter.Eq("notes.title", "Hello MongoDB");

the above should work for you.