Load 2 or more entities

Dec 21, 2014 at 11:12 PM
I've been studying a lot with this framework.
I have a question that if I want to load 2 or more entities e.g Customer and Product tables
What is the best way to do it? Should I call 2 or more times e.g. /odata/Customer and /odata/Product?
Or are there anyways to load all by calling 1 time e.g. /odata/Customer , in the Customer controller, call other service?

Thanks
Coordinator
Dec 22, 2014 at 9:00 PM
You can just call /odata/Customer once and use "expand" in your querystring which is the equivalent of "include" fro IQueryable, e.g. http://localhost/odata/customer?expand=orders, which would give all customers with their order deep loaded.

Reference:

http://www.odata.org/documentation/odata-version-3-0/
Marked as answer by lelong37 on 12/22/2014 at 1:00 PM
Dec 22, 2014 at 9:16 PM
Thanks, but in my case I need to load entities which do not have any relationships each other e.g. Customer and Product, not Customer with Order
Coordinator
Dec 22, 2014 at 9:19 PM
1. You can implement a Web Api controller which could take in the two ID’s and return them both the Customer and Product (will not use OData just plain REST).

2. You can make two separate calls to REST OData one for Customer and the other for Product.