I'm trying to implement a Select
with an Expression to keep the object as an IQueryable and selecting into a child navigation collection
Example Code:
public Expression<Func<Item, ItemModel>> MapToModel =>
Ent => new ItemModel
{
Id = Ent.Id,
Name = Ent.Name,
SKU = Ent.SKU,
Variations = Ent.Variations == null ? default : Ent.Variations.Select(this.VariationMapper),
};
With the VariationMapper being the following:
public Expression<Func<ItemVariation, VariationModel>> VariationMapper =>
Ent => new VariationModel()
{
Id = Ent.Id,
Name = Ent.Name,
};
I receive the following error however:
'ICollection' does not contain a definition for 'Select' and the best extension method overload 'Queryable.Select<ItemVariation, VariationModel>(IQueryable, Expression<Func<ItemVariation, VariationModel>>)' requires a receiver of type 'IQueryable'
I'm a bit perplexed as to how to resolve the issue. Or if this is even possible. That subproperty is type ICollection<T>
as it's a navigation property.