查询使用Breezejs扩展

时间:2013-05-24 12:56:08

标签: breeze

我发送一个带有expand的查询到服务器

var query = breeze.EntityQuery.from("Incidents")
                        .expand("IncidentComments")
                        .where("IncidentID", "eq", incidentId);

并且在http i中获得的结果是可以的,具有相关实体的实体 当我在微风中从查询返回时,我怎么也看不到数据 IncidentComments没有评论

function getSucceeded(data) {
        $scope.incident = data;
        $scope.incidentComments = data.IncidentComments;
    }

1 个答案:

答案 0 :(得分:0)

假设“IncidentComments”是“Incident”的属性,则注释将如此返回。所以:

var query = breeze.EntityQuery.from("Incidents")
                    .expand("IncidentComments")
                    .where("IncidentID", "eq", incidentId);
var myEntityManager.executeQuery(query).then(function (data) {
   var incidents = data.results;
   var incident = incidents[0]; // because you are only returning one incident;
   var incidentComments = incident.incidentComments; 
});