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

夙愿已清 提交于 2019-12-10 03:09:14

问题


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?


回答1:


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 [].



来源:https://stackoverflow.com/questions/14235727/breeze-doesnt-expand-more-than-one-navigation-property-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!