I have a .NET Core 2 web app which has Eshop Product and Price in database. I am using Entity Framework Core. Product can have many prices and can be found in many Eshops. I am making API and I need that it will return Product with it's prices and those prices must be ordered by Eshop ID.
What am I trying is:
context.Products.Include(v => v.Prices.OrderBy(pr=>pr.EshopId)).ThenInclude(e=>e.EShop).Take(100).ToListAsync();
But I am getting error when try to access created API:
An unhandled exception occurred while processing the request. InvalidOperationException: The property expression 'v => {from Price pr in v.Prices orderby [pr].EshopId asc select [pr]}' is not valid. The expression should represent a property access: 't => t.MyProperty'. For more information on including related data, see http://go.microsoft.com/fwlink/?LinkID=746393.
Microsoft.EntityFrameworkCore.Query.ResultOperators.Internal.IncludeExpressionNode.CreateResultOperator(ClauseGenerationContext clauseGenerationContext)
What should I do different to achieve my wanted result?