Generic Join for one-to-one and one-to-many relationships

I finally managed to figure it out:

 var hydratedContact = context.GetCollection<PhoneBookContact>()
    .Aggregate()
    .Match(u => u.Id == id)
    .Lookup(GetCollectionName<PhoneBookContact>(), nameof(PhoneBookContact.ManagerId), "_id", nameof(PhoneBookContact.Manager))
    .Unwind(nameof(PhoneBookContact.Manager))
    .Lookup(GetCollectionName<PhoneBookContact>(), nameof(PhoneBookContact.SecretaryIds), "_id", nameof(PhoneBookContact.Secretary))
    .As<PhoneBookContact>()
    .FirstOrDefault();

I did have to remove the JsonIgnore tags though (I’m actually using a ClassMap and did UnmapMember ) to get the values to populate.

That even works in a generalized way - I just need to follow my Reference tags, get the right type from it and then the collection name.