Я использую следующие выражения:
ProductRepository.Query.Include(Function(x) x.ChildProducts.Select(Function(y) y.PriceTiers.Where(Function(z) z.IsActive))).Where(Function(x) x.Categories.Any(Function(y) y.ID = ID))
И получаю эту ошибку:
The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.
Если я уберу это:
.Where(Function(z) z.IsActive)
Работает нормально, но мне нужно отфильтровать неактивные ценовые уровни.
Есть идеи?
Обновление
Вот мое решение:
Public Function GetProductsByCategoryID(ID As Integer) As System.Collections.Generic.IEnumerable(Of Core.Entities.Product) Implements Core.Interfaces.IProductService.GetProductsByCategoryID
Dim Col = ProductRepository.Query.Where(Function(x) x.Display AndAlso x.Categories.Any(Function(y) y.ID = ID)) _
.Select(Function(x) New With { _
.Product = x,
.ChildProducts = x.ChildProducts.Where(Function(y) y.Display).Select(Function(y) New With { _
.ChildProduct = y,
.PriceTiers = y.PriceTiers.Where(Function(z) z.IsActive)
})
}).ToList.Select(Function(x) x.Product)
Return Col
End Function