MyAspNetCore icon indicating copy to clipboard operation
MyAspNetCore copied to clipboard

Replacing in-memory IDataRepository with EF6.4 doesn't work

Open almarax opened this issue 5 years ago • 0 comments

Steps to reproduce: Create the same data model using EF6.4 and register instead of in-memory repository in DI container

Problem: While a query like http://localhost:41431/odata/Customers?$expand=Orders

works as expected expanding Orders for all customers query to single entity like http://localhost:41431/odata/Customer(1)?$expand=Orders

doesn't expand Orders.

apparently the problem is in [EnableQuery] public IActionResult Get(int key) { return Ok(_repository.GetCustomers().FirstOrDefault(c => c.Id == key)); }

If manually specify eager loading for Orders relationship using Include() it works fine: return Ok(_context.Customers.Include('Orders').FirstOrDefault(c => c.Id == key));

That would work as a workaround if it would be possible to identify and correctly parse all $expand parameters in the query

almarax avatar Feb 10 '20 16:02 almarax