-
Notifications
You must be signed in to change notification settings - Fork 197
Retrieving linked entries without fetching its owners
In addition to expanding results with associated data it's possible to navigate to linked entries directly, without fetching it's relationship principle. The relationship must be defined in OData service schema.
var products = await client
.For("Categories")
.Filter("CategoryName+eq+%27Beverages%27")
.NavigateTo("Products")
.FindEntriesAsync();
Assert.NotEmpty(products);
var products = await client
.For<Categories>()
.Filter(x => x.CategoryName == "Beverages")
.NavigateTo<Products>()
.FindEntriesAsync();
Assert.NotEmpty(products);
var x = ODataFilter.Expression;
var products = await client
.For("Categories")
.Filter(x.CategoryName == "Beverages")
.NavigateTo(x.Products)
.FindEntriesAsync();
Assert.NotEmpty(products);
Request URI: GET Products?$filter=Category%2fCategoryName+eq+%27Beverages%27
var x = ODataFilter.Expression;
var employees = await client
.For("Employees")
.Filter("Superior/FirstName+eq+%27Nancy%27 and Superior/LastName+eq+%27Davolio%27")
.FindEntriesAsync();
Assert.NotEmpty(employees);
var employees = await client
.For<Employees>()
.Filter(x => x.Superior.FirstName == "Andrew" && x.Superior.LastName == "Fuller")
.FindEntriesAsync();
Assert.NotEmpty(employees);
var x = ODataFilter.Expression;
var employees = await client
.For(x.Employees)
.Filter(x.Superior.FirstName == "Andrew" && x.Superior.LastName == "Fuller")
.FindEntriesAsync();
Assert.NotEmpty(employees);
Request URI: GET Employees?$filter=Superior/FirstName+eq+%27Nancy%27 and Superior/LastName+eq+%27Davolio%27
var x = ODataFilter.Expression;
var orders = await client
.For("Employees")
.Filter("FirstName+eq+%27Andrew%27 and LastName+eq+%27Fuller%27")
.NavigateTo("Orders")
.FindEntriesAsync();
Assert.NotEmpty(orders);
var orders = await client
.For<Employees>()
.Filter(x => x.FirstName == "Andrew" && x.LastName == "Fuller")
.NavigateTo<Orders>()
.FindEntriesAsync();
Assert.NotEmpty(orders);
var x = ODataFilter.Expression;
var orders = await client
.For(x.Employees)
.Filter(x.FirstName == "Andrew" && x.LastName == "Fuller")
.NavigateTo(x.Orders)
.FindEntriesAsync();
Assert.NotEmpty(orders);
Request URI: GET Orders?$filter=Employee/FirstName+eq+%27Andrew%27 and Employee/LastName+eq+%27Fuller%27
var orders = await client
.For("Customer")
.Key("ALFKI")
.NavigateTo("Orders")
.FindEntriesAsync();
Assert.NotEmpty(orders);
var orders = await client
.For<Customers>()
.Key("ALFKI")
.NavigateTo<Orders>()
.FindEntriesAsync();
Assert.NotEmpty(orders);
var x = ODataFilter.Expression;
var orders = await client
.For(x.Customers)
.Key("ALFKI")
.NavigateTo(x.Orders)
.FindEntriesAsync();
Assert.NotEmpty(orders);
Request URI: GET Customers('ALFKI')/Orders
var orderDetails = await client
.For("Orders")
.Key(10952)
.NavigateTo("OrderDetails")
.FindEntriesAsync();
Assert.NotEmpty(orderDetails);
var orderDetails = await client
.For<Orders>()
.Key(10952)
.NavigateTo<OrderDetails>()
.FindEntriesAsync();
Assert.NotEmpty(orderDetails);
var x = ODataFilter.Expression;
var orderDetails = await client
.For(x.Orders)
.Key(10952)
.NavigateTo(x.OrderDetails)
.FindEntriesAsync();
Assert.NotEmpty(orderDetails);
Request URI: GET Orders(10952)/OrderDetails
var subordinates = await client
.For("Employees")
.Key(2)
.NavigateTo("Subordinates")
.FindEntriesAsync();
Assert.NotEmpty(subordinates);
var subordinates = await client
.For<Employees>()
.Key(2)
.NavigateTo(x => x.Subordinates)
.FindEntriesAsync();
Assert.NotEmpty(subordinates);
var x = ODataFilter.Expression;
var subordinates = await client
.For(x.Employees)
.Key(2)
.NavigateTo(x.Subordinates)
.FindEntriesAsync();
Assert.NotEmpty(subordinates);
Request URI: GET Employees(1)/Subordinates
var superior = await client
.For("Employees")
.Key(1)
.NavigateTo("Superior")
.FindEntryAsync();
Assert.NotNull(superior);
var superior = await client
.For<Employees>()
.Key(1)
.NavigateTo(x => x.Superior)
.FindEntryAsync();
Assert.NotNull(superior);
var x = ODataFilter.Expression;
var superior = await client
.For(x.Employees)
.Key(1)
.NavigateTo(x.Superior)
.FindEntryAsync();
Assert.NotNull(superior);
Request URI: GET Employees(1)/Superior
var superior = await client
.For("Employees")
.Filter("EmployeeID+eq+1")
.NavigateTo("Superior")
.FindEntryAsync();
Assert.Equal(2, superior.EmployeeID);
var superior = await client
.For<Employees>()
.Filter(x => x.EmployeeID == 1)
.NavigateTo(x => x.Superior)
.FindEntryAsync();
Assert.Equal(2, superior.EmployeeID);
var x = ODataFilter.Expression;
var superior = await client
.For(x.Employees)
.Filter(x.EmployeeID == 1)
.NavigateTo(x.Superior)
.FindEntryAsync();
Assert.Equal(2, superior.EmployeeID);
Request URI: GET Employees(1)/Superior
See also:
Expanding results with linked entries
Retrieving data