Breeze doesn't expand more than one navigation property path?
Asked Answered
P

1

9

if I run the following query using the NorthindModel, NorthwindDataContext from the breeze samples only the first navigation property is expaned. All other returning null:

    var query = EntityQuery.from("OrderDetails")
        .where("OrderID", "==", 11069)
        .expand("Order.Customer", "Order.Employee");
    manager.executeQuery(query).then(querySucceeded).fail(queryFailed);

    function querySucceeded(data){
         var customer = data.results[0].Order().Customer();
         var employee = data.results[0].Order().Employee(); // returns null!!!!!
    }

If I change the order in the expand paramerter list than customer is set to null:

    var query = EntityQuery.from("OrderDetails")
        .where("OrderID", "==", 11069)
        .expand("Order.Employee", "Order.Customer");
    manager.executeQuery(query).then(querySucceeded).fail(queryFailed);

    function querySucceeded(data){
         var customer = data.results[0].Order().Customer(); // returns null!!!!!
         var employee = data.results[0].Order().Employee();         }

What's the problem here?

Price answered 9/1, 2013 at 12:57 Comment(0)
B
11

The 'expand' method takes a single argument that is either an array or a comma delimited string. You gave it two arguments. So try the following instead.

var query = EntityQuery.from("OrderDetails") .where("OrderID", "==", 11069) .expand(["Order.Customer", "Order.Employee"]);

Note the [].

Bhang answered 9/1, 2013 at 18:43 Comment(3)
Ok, the docs on breeze.js seems to be a mess....that took me hours. breezejs.com/documentation/navigation-propertiesPrice
The API Docs are sometimes a better place to look: breezejs.com/sites/all/apidocs/classes/…Bhang
I updated the commentary on expand in breezejs.com/documentation/navigation-properties in hopes that the next person does not struggle as you did. Is there something else we can do to make this more clear? Thanks for the feedback.Favour

© 2022 - 2024 — McMap. All rights reserved.