breezejs导航属性包括不工作

时间:2013-06-11 12:10:22

标签: entity-framework breeze hottowel

我编写了服务器端代码,其中包含多对多关系的导航属性,如下所示。

var result = _contextProvider.Context.ResourceProperty.Include("AssociatedStandardResourceProperty.AssociatedLists").Where(t => t.ResourceId == resId);
        //Return matching resource properties
        return result;

但是,当我尝试从breeze datacontext检索数据时,我收到查询执行错误,如下所示。

var getResourceProperties = function (resourceId, resourcePropertyObservable) {

        var query = EntityQuery.from('GetResourceProperties')
            .withParameters({ resourceId: resourceId })
            .expand("AssociatedStandardResourceProperty.AssociatedLists");

        return manager.executeQuery(query)
            .then(querySucceeded)
            .fail(queryFailed);

        function querySucceeded(data) {
            if (resourcePropertyObservable) {
                resourcePropertyObservable(data.results);
            }
            log('Retrieved listObservable from remote data source',
                data, true);
        }
    };

查询失败,所有数据都在我用queryFailed函数编写的日志消息中检索。

我还检查过在客户端删除展开,同时删除服务器端的include,然后在客户端进行扩展。

请让我知道如何让它发挥作用。

由于

2 个答案:

答案 0 :(得分:1)

我观察到这个问题是由于两个实体之间的多对多映射造成的。删除关系后,我们可以检索associatedEntities数据

答案 1 :(得分:0)

这里只是猜测,但如果您在服务器上执行 include ,那么您不需要客户端上的 expand ,反之亦然。你的例子似乎在做两件事。你得到的错误信息是什么?