.net WebApi OData +微风=> [Q]未处理的拒绝原因(应为空) [英] .net WebApi OData + breeze => [Q] Unhandled rejection reasons (should be empty)
问题描述
我有一个带有OData EntitySetController的.net 4.5 Web Api
I have a .net 4.5 Web Api with OData EntitySetController
在客户端,我加载了以下js文件
In client side I got the following js files loaded
jquery.min.js
q.min.js
datajs-1.1.1.min.js
breeze.debug.js
toastr.min.js
angular.js
当我调用以下javascript
when I call the following javascript
breeze.config.initializeAdapterInstance("dataService", "OData");
var manager = new breeze.EntityManager(serviceName);
var query = breeze.EntityQuery.from("Customers");
return manager.executeQuery(query).then(success).fail(fail);
function success(data) {
$log.info("Retrieved " + data.results.length);
return data.results;
}
function fail(data) {
$log.info("error " + data);
}
我在chrome网络标签中看到以下内容,其中显示了元数据,而json数据又很好地返回了...
I see the following in my chrome network tab showing metadata and the json data are coming back nicely...
Request URL:http://localhost:49971/odata/$metadata
Status Code:200 OK, 1.8KB
Request URL:http://localhost:49971/odata/Customers
Status Code:200 OK, 3.3KB
但是成功回调永远不会触发,失败回调将被执行.有人可以帮忙吗?我所看到的就是
BUT the success callback never fires, the fail callback gets executed. Can any one help please? All I see is
XHR finished loading: "http://localhost:49971/odata/$metadata". datajs-1.1.1.min.js:14
XHR finished loading: "http://localhost:49971/odata/Customers". datajs-1.1.1.min.js:14
[Q] Unhandled rejection reasons (should be empty):
[Error]
length: 0
__proto__: Array[0]
q.js:1010
error Error: OK
然后我需要将它们数据绑定到ng-grid,ng-form,最后将它们发送回数据库到服务器端...
I then need to databind these to a ng-grid, ng-form and then finally send them back to database to serverside...
更多代码和屏幕截图
breeze.EntityQuery
.from("AddressTypes")
.using(new breeze.EntityManager(serviceName))
.execute()
.then(function(data) {
console.log(data); // never gets here very wierd
}).fail(function(e) {
console.log(e); // shows an error object with the AddressType Array
});
我在失败回调中看到AddresTypes数组...
I see the AddresTypes array in fail callback...
更新:我已经在后端临时切换到BreezeContoller而不是EntitySetController,并注释掉了breeze.config.initializeAdapterInstance("dataService", "OData");
,我在successCb中得到了我的数组.所以我想我可以推断我在DataJS方面遇到了麻烦.真的很想坚持使用EntitySetController ...
update: I have temporarily switched to a BreezeContoller instead of EntitySetController in the backend, and commented out breeze.config.initializeAdapterInstance("dataService", "OData");
And I get my array in successCb. So I think I can infer I am running into trouble with DataJS. Really would like to stick with EntitySetController though...
推荐答案
我遇到了同样的问题. 事实证明,回到datajs 1.0.3似乎可行. 但是,这样做导致$ expand无法工作(服务器可以工作,但是微风无法处理它的导航属性->不管其多重性如何.)
I had the same problem. As it turned out, going back to datajs 1.0.3 seemed to work. However, doing that resulted $expand to not work (the server works, but breeze doesn't handle it the navigation properties -> regardless its multiplicity).
我必须说,我想寻找一个与 STABLE breezejs相当的产品.
I must say, I am terrible looking for a STABLE breezejs equivalent.
这篇关于.net WebApi OData +微风=> [Q]未处理的拒绝原因(应为空)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!