WebApi icon indicating copy to clipboard operation
WebApi copied to clipboard

$expand functionality is not supporting in EF Core

Open AnvardeenBatcha opened this issue 5 years ago • 4 comments

OData Expand is throwing error while trying to filter the child entitities.

For example, I just followed the below example. But $expand functionality is not supporting and throwing error. Please assist. Referred the below URL's to fix the expand functionality. But it didn't work.

https://wellsb.com/csharp/aspnet/odata-api-ef-core-blazor/ https://devblogs.microsoft.com/odata/enabling-endpoint-routing-in-odata/ https://devblogs.microsoft.com/odata/experimenting-with-odata-in-asp-net-core-3-1/

Example Request URL : http://localhost:55145/odata/weatherforecast?$expand&=WeatherForecast

Technical details EF Core version: 3.1.4 Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET Core 3.1) Operating system: IDE: (e.g. Visual Studio 2019 16.3)

AnvardeenBatcha avatar Jul 14 '20 05:07 AnvardeenBatcha

Can you try the without the '&' right after the $expand. So the query would be $expand=WeatherForecast.

Mhirji avatar Jul 14 '20 06:07 Mhirji

Previously i have mentioned URL wrongly. Please check the below one. The exact URL is : http://localhost:55145/odata/weatherforecast?$expand=customer($filter=Name eq 'Test')

Entity structure: public class WeatherForecast { public Guid Id { get; set; } public DateTime Date { get; set; } public int TemperatureC { get; set; } public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); public string Summary { get; set; } public Customer Customer { get; set; } }

public class Customer
{
    public Guid Id { get; set; }
    public string Name { get; set; }
}

AnvardeenBatcha avatar Jul 14 '20 08:07 AnvardeenBatcha

@AnvardeenBatcha can you share a reproduction of the issue and the exact error message that you are getting.

ElizabethOkerio avatar Jul 14 '20 16:07 ElizabethOkerio

@AnvardeenBatcha Was this issue resolved?

KenitoInc avatar May 18 '22 08:05 KenitoInc

Closing this issue due to inactivity. If this issue still persists, feel free to create a new issue.

KenitoInc avatar Feb 10 '23 08:02 KenitoInc

Closing this issue due to inactivity. If this issue still persists, feel free to create a new issue.

KenitoInc avatar Feb 10 '23 08:02 KenitoInc