In our data model we have hierarchical data. We have for example the following structure:
Product : Category (one to many)
Category : CategoryType (one to many)
If we want to have a certain Product's related categories and also each category's related categorytypes we can build this up with a url like this:
<urlbase>/Products(1)?$expand=Category($expand=CategoryType)
This works fine in the browser. The question is how this can be done in the simple.odata.client OData v4? We are trying this but not getting it to to work:
var client = new ODataClient(ConfigSettingsProvider.ODataBaseUri);
var client
.For<Product>()
.Filter(p=> p.Id == 1)
.Expand(p => p.Categories)
.Expand(c => c.CategoryTypes)
.FindEntriesAsync();
Please check Simple.OData.Client tests that contain both untyped, typed and dynamic versions:
Untyped: https://github.com/object/Simple.OData.Client/blob/master/Simple.OData.Client.Tests.Net40/FindTests.cs
Typed: https://github.com/object/Simple.OData.Client/blob/master/Simple.OData.Client.Tests.Net40/FindTypedTests.cs