How to populate array from mongoDb un Dotnet Core?


I would like to inquire regarding the query of data from a database in MongoDb.

I’m learning about it, and the documentation is still a bit difficult for me to understand.

The thing is, I want to fetch some data from a collection that contains an array of IDs from another collection.

In Javascript the ** populate ** instruction would be used, but I still don’t understand how I can use ** linq ** or ** Lookup ** to get the same result.

The entities are basically:

public sealed class Person
    {
        (BsonId)
        (BsonRepresentation(BsonType.ObjectId))
        public String id { get; set; }
        public List<Qr> codigoQr { get; set; } = new List<Qr>();
    }

and

public sealed class Qr
    {
        public Qr()
        {}

        (BsonId)
        (BsonRepresentation(MongoDB.Bson.BsonType.ObjectId))
        public String id { get; set; }
    }

To get the people from the Db I am using:

var docs = _persons.Aggregate()
                     .Lookup("Qr", "id", "codigoQr", "asAccounts")
                     .As<MongoDB.Bson.BsonArray>()
                     .ToList();

            return docs;

but i get the error:

System.FormatException: An error occurred while deserializing the codigoQr property of class HCS.Models.Person: Expected a nested document representing the serialized form of a HCS.Models.Qr value, but found a value of type ObjectId instead.

I have tried ** Linq ** but I don’t understand how to use the ** join ** statement to populate the data in the array.

Basically I have in db a list of people with the following format:

{
    "_id": {
        "$oid": "5f5993182939e4f2446ed47a"
    },
    "name": "Pablo",
    "lastname": "Mederos",
    "codigoQr": ({
        "$oid": "5f59948f2939e4f2446ed47c"
    },
    {
        "$oid": "5f59948f2939e4f2446ed47c"
    })
}

Is there a way to populate that list with the data from the Qr collection?

From already thank you very much!