【问题标题】:breezejs navigation property with include not working包含不工作的微风导航属性
【发布时间】:2013-08-08 15:13:17
【问题描述】:

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

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

但是,当我尝试从微风数据上下文中检索数据时,我收到如下所示的查询执行错误。

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 函数编写的日志消息中检索。

我还检查了通过在客户端删除扩展并在服务器端删除包含然后在客户端包括扩展。

请告诉我如何使它工作。

谢谢

【问题讨论】:

  • 我已经检查了服务器端的数据是否在结果变量中的微风控制器操作中正确填充。

标签: entity-framework breeze hottowel


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    这里只是一个猜测,但是如果您在服务器上执行 include,那么您不需要在客户端上执行 expand,反之亦然。你的例子似乎是两者兼而有之。您收到的错误消息是什么?

    【讨论】:

    • 这是我在 chrome 控制台中遇到的错误日志“Object.ajaxImpl.ajax.success at createError at Object.self.fireWith [as resolveWith] /scripts/jquery-1.9. 1.js:1148:7) 在完成 (/scripts/jquery-1.9.1.js:8074:14) 在 XMLHttpRequest.callback (/scripts/jquery-1.9.1.js:8598:8) 从上一个事件:在 promiseWithCallbacks (breeze.debug.js:11237:31) 在浏览器中,它在 toastr 日志中显示完整的 JSON 数据。我通过删除 expand("AssociatedStandardResourceProperty.AssociatedLists") 进行了检查,但我仍然得到相同的结果。
    • 我观察到问题是由于两个实体之间的多对多映射造成的。删除关系后,我们能够检索关联实体数据
    猜你喜欢
    • 2014-01-19
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-23
    相关资源
    最近更新 更多