MongoDB.Driver query to mimic what Realm is doing

I’ve got a rather complex object that I’ve setup for use with Realm

	[MapTo("products")]
	public class ProductDto : RealmObject
	{
		[MapTo("_id"), JsonProperty("_id"), PrimaryKey] public string Id { get; init; }
		[MapTo("_partitionKey"), JsonProperty("_partitionKey"), Required] public string PartitionKey { get; init; } = Constants.MasterDataPartitionKey;
		public string BrandId { get; init; }
		public BrandDto Brand { init; get; }
                // truncated for brevity
        }

	[MapTo("brands")]
	public class BrandDto : RealmObject
	{
		[MapTo("_id"), JsonProperty("_id"), PrimaryKey] public string Id { get; init; }
		[MapTo("_partitionKey"), JsonProperty("_partitionKey"), Required] public string PartitionKey { get; init; } = Constants.MasterDataPartitionKey;
		public string ProducerId { get; init; }
		public string Name { get; init; }
		public ProducerDto Producer { get; init; }
	}
	[MapTo("producers")]
	public class ProducerDto : RealmObject
	{
		[MapTo("_id"), JsonProperty("_id"), PrimaryKey] public string Id { get; init; }
		[MapTo("_partitionKey"), JsonProperty("_partitionKey"), Required] public string PartitionKey { get; init; } = Constants.MasterDataPartitionKey;
		public string Name { get; init; }
		public ContactInformationDto ContactInformation { get; init; }
		public IList<AddressDto> Locations { get; }
	}

Now because these three objects are "RealmObject"s, they’re represented in my collections as ID references. Below is a snapshot of a “Product”
image

So this is all well and good for my Xamarin application and Realm seems to be doing exactly what it needs to. The problem comes when I try and extend these DTO’s to my API.

In the API, I cannot use Realm and instead I need to use the MongoDb Driver. What is the correct approach to structuring these shared DTOs, and how do I write queries to satisfy the MongoDB.Driver?

I should note, I started with a linq query

var results = (from product in products.AsQueryable()
		join brand in (from brand in brands.AsQueryable()
				join producer in producers.AsQueryable() on
					brand.ProducerId equals producer.Id
				select new BrandDto
				{
					Id = brand.Id,
					Producer = producer,
					Name = brand.Name
				}) on
			product.BrandId equals brand.Id
		select new ProductDto
		{
			Id = product.Id,
			Brand = brand
		})
	.ToList();

But got an exception

 System.ArgumentException: Expression of type 'System.Collections.Generic.IEnumerable`1[cannect.Data.Features.Producers.BrandDto]' cannot be used for parameter of type 'System.Linq.IQueryable`1[cannect.Data.Features.Producers.BrandDto]' of method 'System.Linq.IQueryable`1[cannect.Data.Features.Producers.BrandDto] Join[BrandDto,ProducerDto,String,BrandDto](System.Linq.IQueryable`1[cannect.Data.Features.Producers.BrandDto], System.Collections.Generic.IEnumerable`1[cannect.Data.Features.Producers.ProducerDto], System.Linq.Expressions.Expression`1[System.Func`2[cannect.Data.Features.Producers.BrandDto,System.String]], System.Linq.Expressions.Expression`1[System.Func`2[cannect.Data.Features.Producers.ProducerDto,System.String]], System.Linq.Expressions.Expression`1[System.Func`3[cannect.Data.Features.Producers.BrandDto,cannect.Data.Features.Producers.ProducerDto,cannect.Data.Features.Producers.BrandDto]])' (Parameter 'arg0')

So I moved onto Lookups

var results = await products.Aggregate()
	.Lookup(brands, product => product.BrandId, brand => brand.Id, (ProductDto x) => x.Brand)
	.ToListAsync();

but got a different exception

System.InvalidOperationException: Unable to determine the serialization information for x => (x As BrandDto).

and also, I just don’t know how to flesh out these lookups