简体   繁体   English

Breeze.js OData v4错误

[英]Breeze.js OData v4 Error

I am trying to create a simple JavaScript application using Breeze.js version 1.5.3. 我正在尝试使用Breeze.js版本1.5.3创建一个简单的JavaScript应用程序。 It is to consume an OData v4 service. 这将消耗OData v4服务。 The service is created with ASP.NET WebApi 2. 该服务是使用ASP.NET WebApi 2创建的。

Included scripts: 包含的脚本:

<script src="/js/jquery.min.js"></script>
<script src="/js/underscore.js"></script>
<script src="/js/q.js"></script>
<script src="/js/datajs-1.1.3.js"></script>
<script src="/js/breeze.debug.js"></script>

Here is the code configuring Breeze's EntityManager: 这是配置Breeze的EntityManager的代码:

var serverAddress = "http://localhost:6405/odata/";
breeze.config.initializeAdapterInstances({ dataService: "webApiOData4" });
var manager = new breeze.EntityManager(serverAddress);

The code fails with the following error: Uncaught TypeError: Cannot read property 'oData' of undefined Here is the snippet from breeze.debug.js that fails (around line 16591): 代码失败,并出现以下错误: Uncaught TypeError: Cannot read property 'oData' of undefined这是来自breeze.debug.js的代码段,失败了(约16591行):

webApiOData4Ctor.prototype.initialize = function () {
    // Aargh... they moved the cheese.
    var datajs = core.requireLib("datajs", "Needed to support remote OData v4 services");
    OData = datajs.V4.oData; // V4 is undefined, so it throws
    OData.json.jsonHandler.recognizeDates = true;
};

I have searched through datajs-1.1.3.js and found no 'V4' symbol. 我搜索了datajs-1.1.3.js ,未发现“ V4”符号。 Moreover the authors of this library say that it only supports OData v3. 此外,该库的作者说它仅支持OData v3。 Some suggest to use odatajs-4.0.0-beta-01.min.js found here http://olingo.apache.org/doc/javascript/ , but there is a clear dependency on datajs in breeze.debug.js source code. 有些人建议使用http://olingo.apache.org/doc/javascript/上找到的odatajs-4.0.0-beta-01.min.js ,但是breeze.debug.js源代码中对datajs依赖很明显。 。 I have tried to include odatajs-4.0.0-beta-01.min.js script in my page but it has not helped. 我试图在页面中包含odatajs-4.0.0-beta-01.min.js脚本,但没有帮助。

Does anybody know how to make Breeze.js work with OData v4 service? 有人知道如何使Breeze.js与OData v4服务一起使用吗?

Breeze does not yet work with OData 4.0 because of a number of issues with MS OData library. 由于MS OData库存在许多问题,因此Breeze尚未与OData 4.0一起使用。 They are aware of the issues and are planning a release that fixes them soon... We are working with them and will try to release our OData 4.0 support when this happens. 他们已经意识到了这些问题,并正在计划尽快解决这些问题。我们正在与他们合作,并在发生这种情况时尝试释放对OData 4.0的支持。 We will also be using the 'olingo' datajs library in order to support OData 4.0. 我们还将使用“ olingo” datajs库来支持OData 4.0。

Note that you do NOT need OData to use breeze (especially with ASP.NET WebApi2). 请注意,不需要OData即可使用微风(尤其是在ASP.NET WebApi2中)。 See: http://www.getbreezenow.com/documentation/aspnet-web-api .And you actually get more capabilities and better performance if you do NOT: See http://www.getbreezenow.com/documentation/odata-vs-webapi 请参阅: http : //www.getbreezenow.com/documentation/aspnet-web-api 。如果不这样做,您实际上会获得更多的功能和更好的性能:请参阅http://www.getbreezenow.com/documentation/odata-vs -webapi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM