微风查询错误,即使结果返回 [英] Breeze query error, even though results returned

查看:189
本文介绍了微风查询错误,即使结果返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

微风被调用失败()函数,即使数据似乎从ODATA服务返回(以及在错误的对象是)。有5个交易中的数据被传递到失败函数的错误对象的属性。从ODATA服务(如被看见在Chrome开发者工具)的返回,以及

Breeze is calling the "fail()" function, even though the data seems to be returned from the odata service (as well as being in the error object). There are 5 "transactions" returned from the ODATA service (as seen in Chrome developer tools) as well as in the "data" property of the error object being passed to the fail function.

调用code是这样的:

Calling code looks like this:

    function getTransactions() {
        var query = breeze.EntityQuery.from("Transactions")
                        .take(5);

        return entityManager.executeQuery(query,
            function(data) {
                log("transaction Query success!");
                var transactions = data.results;
            },
            function(err) {
                log("Query failed:" + err.message);
            });
    }

我很茫然,什么是错的,是造成故障()。

I am at a loss as to what is wrong that is causing the "fail()."

有是事务构造函数中定义,code如下:

There IS a Transaction constructor defined, code below:

   function registerTransactions(metadataStore) {
        metadataStore.registerEntityTypeCtor('Transaction', Transaction);

        // constructor -- empty
        function Transaction() { };

        Object.defineProperty(Transaction.prototype, 'itemCount', {
            get: function () {
                return 0;
            }
        });
    }

请注意为ODATA资源的URL是交易,但实体交易。什么是为什么失败()函数将被调用的原因?

Note the url for the odata resource is "Transactions" but the entity is Transaction. What are the reasons why the "Fail() function would be called?

返回Error.message =;这是没有帮助太多

Error.message = "; " which isn't helping much.

我相信我是在最新的1.4.11微风和datajs 1.1.2

I believe I am on the latest Breeze 1.4.11 and datajs 1.1.2

推荐答案

经过大量的研究,我发现这个问题是另一个funcky CORS在服务端设置。我能够通过对同一服务直接前往dataJS,并得到更翔实的错误消息,看着办吧。

After much research, I found the problem was another funcky CORS setting on the service side. I was able to figure it out by going directly to dataJS against the same service, and getting a more informative error message.

你必须做什么服务端是这样的:

What you MUST do on the service side is something like this:

VAR CORS =新EnableCorsAttribute(*,*,*,DataServiceVersion,MaxDataServiceVersion);

最后一个参数具有与服务在标题发送的OData版本,从而允许客户机以确定它是否能够处理的OData的指定版本

The last parameter has to with the service sending the OData version in the header and thereby allowing the client to determine if it can handle the specified version of OData.

如果有谁知道这个的更多详细信息,请随时发表评论。

If anyone knows more details about this, feel free to comment.

这篇关于微风查询错误,即使结果返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆