Lookup on ObjectIds in an array of strings in .Net

52 Views Asked by At

Suppose I have a collection Book with a field Genres as following:

Book: { 
_id: ObjectId('id')
Title: "Book1"
Genres: {"id1","id2"}
}

And a second collection Genre:

Genre: [{
_id: ObjectId('id1')
Title: "Thriller"
},{
_id: ObjectId('id2')
Title: "Fantasy"
}]

When I perform lookup on the two collections to apply some filters on the Title, the result I get is an empty array. How can I parse the strings ids to ObjectId while I'm performing my lookup aggregation?

I'm kinda new to mongodb and can not find enough resources to help me out. Hope someone can help me find the solution in c# .net

0

There are 0 best solutions below