.net WebApi OData + breeze => [Q] Unhandled rejection reasons (should be empty)

落花浮王杯 提交于 2019-12-30 08:59:22

问题


I have a .net 4.5 Web Api with OData EntitySetController

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

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);
}

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 

I then need to databind these to a ng-grid, ng-form and then finally send them back to database to serverside...

Some more code and screen shot

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
  });

I see the AddresTypes array in fail callback...

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...


回答1:


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).

I must say, I am terrible looking for a STABLE breezejs equivalent.



来源:https://stackoverflow.com/questions/17986818/net-webapi-odata-breeze-q-unhandled-rejection-reasons-should-be-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!