This repository is meant to show a problem involving OData, Automapper and EntityFrameworkCore when flattening a database one to many
relations into a one to one
relation for DTO classes.
With this scenario, it's impossible to query DTOs child entity without breaking OData response.
Just clone this repository and launch the project. Try to make this HTTP request and see the broken response:
/api/parents?$expand=Child&$filter=Id eq 4 or Child/Id eq 4
Multiple problems are to be found here:
- The LinqToSql query generated by OData cannot be converted to SQL.
- OData startes the response streaming before the database access, and this leads to a broken output (it should break with an exception). See this image