Ok, I was unable to reproduce the first part of your error (shown below). I do not have a copy of the "CodeCamper" database but I've run the same test with our test db ( a version of Northwind) and manager.getEntities returns an array that it the same length as data.results.length. So I'm not sure what's going on there.
var query = entityModel.EntityQuery.from("Categories"); manager.executeQuery(query).then(function (data) { alert(data.results.length); //this returns 45 results alert(manager.getEntities().length); // this returns 0 results. WHY???? });
As for "executeQueryLocally", it can only execute if the entityManager cache already has data in it. I cannot tell from your example, but is it possible that you are calling getByParentUrl before any call to getData has completed. Your getData method is asynchronous whereas your getByParentUrl is not, so you need to make sure that your getData call completes before calling getParentUrl.
If you continue to have issues, can you post a copy of your server side controller?
|
Hi there,
I've been developing a SPA based on John Papa's example of code camper. I came across with breeze.js and I really want to use this rather than building my own client db context. So far it is OK, but like in code camper example I want to load some data from dataprimer and que the results as needed from local cache. but everytime I tried executeQueryLocally I got 'entityType is null' error. When I check getEntities() to see if I got the results in cached it returns blank but if I check data.results then there are results. my code is
define('dataservice.categories', ['jquery', 'underscore', 'ko', 'config', 'utils','breeze', 'store'], function ($, _, ko, config, utils, breeze, store) {
var entityModel = breeze.entityModel, core = breeze.core;
// configure Breeze for Knockout and Web API core.config.setProperties({ trackingImplementation: entityModel.entityTracking_ko, remoteAccessImplementation: entityModel.remoteAccess_webApi });
// service name is route to the Web API controller var serviceName = '/api/breeze';
// manager is the service gateway and cache holder var manager = new entityModel.EntityManager(serviceName);
var getData = function () { var query = entityModel.EntityQuery.from("Categories"); manager.executeQuery(query).then(function (data) { alert(data.results.length); //this returns 45 results alert(manager.getEntities().length); // this returns 0 results. WHY???? }); }, getByParentUrl = function (url, results) { var query = entityModel.EntityQuery.from("Categories"); query = query.where("Parent.FriendlyUrl", "==", null); manager.executeQueryLocally(query); //I think this is the line where I got 'entityType is null' error }
return { getData: getData, getByParentUrl: getByParentUrl }
});
Please let me know if you have any question Thank you,
|