0
votes

I am trying to create a simple JavaScript application using Breeze.js version 1.5.3. It is to consume an OData v4 service. The service is created with 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:

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

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. Moreover the authors of this library say that it only supports 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. I have tried to include odatajs-4.0.0-beta-01.min.js script in my page but it has not helped.

Does anybody know how to make Breeze.js work with OData v4 service?

1

1 Answers

1
votes

Breeze does not yet work with OData 4.0 because of a number of issues with MS OData library. 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. We will also be using the 'olingo' datajs library in order to support OData 4.0.

Note that you do NOT need OData to use breeze (especially with 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