// There is no way to refer to a let variable ($$products) from a lambda function.
|
// We have to use a BsonDocument (strings unfortunately) to define our lookup pipeline.
|
private const string DeliveriesLookupPipelineString = @"
|
{$match:{
|
$expr:{
|
$and:[
|
{$in:[""$productId"",""$$products.productId""]},
|
{$eq:[""$deliveryType"",""Sample""]},
|
{$eq:[""$availability"",""Released""]}
|
]
|
}
|
}
|
}
|
";
|
|
private static readonly PipelineDefinition<Delivery, Delivery> DeliveriesLookupPipeline = new[]
|
{
|
BsonDocument.Parse(DeliveriesLookupPipelineString)
|
};
|
...
|
.Lookup<SearchAugmentedProductType, Delivery, Delivery, IEnumerable<Delivery>,
|
SearchAugmentedProductType>(
|
_deliveries,
|
new BsonDocument { { "products", "$products" } },
|
DeliveriesLookupPipeline,
|
searchAugmentedProductType => searchAugmentedProductType.Deliveries)
|
...
|