Projections on a nested collection



I have a collection of products and by convention we've added the variants as a property so they are indexed together.
What I'd like to do is project over the results and get the cheapest variant in order to retreive some data to be displayed. This prevents me from loading all variants when the search results.

Is it possible, when projecting, to filter a nested collection?


  .Filter(x => x.Code.Match("8801141522433"))  
  .Select(p => new
    Code = p.Code,
    SpecificationsList = p.ProductVariations.FirstOrDefault(v => v.Code == p.CheapestVariationCode).Specifications   })

The SpecificationsList is always empty because Find cannot interpret the FirstOrDefault method I guess but I can't Filter there either.

Thanks for helping out!


Edited, Jun 14, 2017 22:49

Not sure if it's what you need but if in your example the ProductVariations property had been a Dictionary where you can predict the key it will work with Find.

Jun 14, 2017 23:40
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.