MyAspNetCore
MyAspNetCore copied to clipboard
Replacing in-memory IDataRepository with EF6.4 doesn't work
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