Breeze OData错误 [英] Breeze OData error
问题描述
我已尝试一段时间使用微风和OData。
I've been trying for some time now to use breeze and OData.
我的OData来自另一个服务器,并启用CORS。我相信问题是与微风和odata,因为我使用breeze和web api测试了一切,它的工作很好。
My OData comes from another server, and CORS is enabled. I believe the problem is with breeze and odata because I've tested everything using breeze and web api and it worked just fine.
在chrome在网络选项卡我看到OData正确抓取,但由于某些原因数据未显示,我得到这个奇怪的错误:
In chrome in network tab I see that OData is fetched properly but for some reason data isn't shown and I get this strange error:
[Q] Unhandled rejection reasons (should be empty):
[Error]
q.js:891
Error: OK Logger.js:52
Here is my breeze DataService:
app.adminMuscleGroup.dataService = ( function(breeze, logger) {
breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);
var service = new breeze.DataService({
serviceName: "http://localhost:23758/odata/",
hasServerMetadata: false,
});
breeze.config.initializeAdapterInstance("dataService", "OData");
var manager = new breeze.EntityManager({ dataService: service });
manager.enableSaveQueuing(true);
var dataService = {
getAll: getAll,
};
return dataService;
function getAll() {
var query = breeze.EntityQuery.from("MuscleGroup").orderBy("Name");
return manager.executeQuery(query);
}
这里是Controller.js:
Here is Controller.js:
app.adminMuscleGroup.controller('AdminMuscleGroupCtrl', function ($scope) {
var dataService = window.app.adminMuscleGroup.dataService;
var logger = window.app.logger;
$scope.items = [];
$scope.getAllMuscleGroups = function() {
dataService.getAll()
.then(querySucceeded)
.fail(queryFailed);
};
$scope.getAllMuscleGroups();
function querySucceeded(data) {
$scope.items = [];
data.results.forEach(function(item) {
$scope.items.push(item);
});
$scope.$apply();
logger.info("Fetched all Muscle Groups");
}
function queryFailed(error) {
logger.error(error.message, "Query failed");
}
})
这里是控制台日志的屏幕截图:
Here is screenshot of Console log:
推荐答案
我发现,对于OData和CORS使用常规EntitySetController时,微风并不能正常工作,你可以在问题我问这里,让他们工作控制器应该是一个常规的ApiController装饰的BreezeControllerAttribute从 Breeze.WebApi 。它可能已经更新工作,但我没有尝试过一段时间。
I found out that breeze doesn't work correctly when using regular EntitySetControllers for OData and CORS as you can see in the question I asked here, and that to get them to work the controller should be a regular ApiController decorated with the BreezeControllerAttribute from Breeze.WebApi. It might have already been updated to work but I haven't tried it in a while.
这篇关于Breeze OData错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!