I have a many queries with pagination working normally with Breeze 1.4.5 (legacy), EF 5, the WebApi.
However being a project that will be maintained over the long term was set to keep updated technologies applied not even be possible due to their complexity.
Consequently the project has been updated to use EF6, ASP MVC 5 and WebApi 2 with the following steps How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2 and Breeze documentation.
After updating everything was ok except the need to add [BreezeQueryable(MaxExpansionDepth = [n])]
or [BreezeQueryable(MaxNodeCount = [n])]
attribute(s) in ApiController methods.
The biggest problem now is that the return of 'data.inlineCount' is always 'undefined' and it totally breaks the pagination logic.
Note that the problem occurs also in methods without any attribute except 'HttpGet' which is not Breeze inlineCount is undefined case and in queries with select on the client side without select everything will normal.
One thing that was not mentioned is that in the analysis of the response using Fiddler and Chrome dev tools the fragment of 'InlineCount' not there only the results array.
In query profiler SQL is correct and contains elements for counting.
Using the TempHire sample and then only for test on 'Resource Management' screen change the repository.js on 'all' function place .inlineCount(true):
this.all = function () {
var query = breeze.EntityQuery
.from(resourceName)
.inlineCount(true);
return executeQuery(query);
};
All is well with the result: 'InlineCount: 9' Now put a select:
this.all = function () {
var query = breeze.EntityQuery
.from(resourceName)
.select('Address1, Address2, City, FullName, Id, PhoneNumber, State, Zipcode')
.inlineCount(true);
return executeQuery(query);
};
We will no longer $id, $type and InlineCount only the results array. This behavior does not exist in the previous version.
Follows a large common query in use:
function getOrdensServico(observable, criteria, pagingInfo) {
var query = entityQuery.from(info.ordemServico.entitySet)
.select('idOrdemServico, numeroOrdemServico, dataOrdermServico, situacaoOrdemServico, conta, departamento, usuario')
.orderBy(info.ordemServico.orderBy);
if (criteria) {
criteria = criteria();
if (criteria.numero()) {
query = query.where('numeroOrdemServico', '==', criteria.numero());
}
if (criteria.situacao()) {
query = query.where('situacaoOrdemServico', '==', criteria.situacao());
}
if (criteria.nomeDepartamento()) {
query = query.where('departamento.nomeDepartamento', 'contains', criteria.nomeDepartamento());
}
if (criteria.dataCriadaEntre() > 0) {
var pred = utl.createBetweenPredicateFromDays("dataOrdermServico", criteria.dataCriadaDe, criteria.dataCriadaEntre);
query = query.where(pred);
}
}
if (pagingInfo) {
var currentPage = ko.utils.unwrapObservable(pagingInfo.currentPage),
pageSize = ko.utils.unwrapObservable(pagingInfo.pageSize);
query = query.skip(currentPage * pageSize).take(pageSize).inlineCount(true);
}
return datacontext.manager.executeQuery(query.toType(info.ordemServico.entityName))
.then(querySucceeded)
.fail(queryFailed);
function querySucceeded(data) {
utl.safeSetCollection(observable, data.results);
if (pagingInfo) {
pagingInfo.inlineCount(data.inlineCount || data.results.length);
}
logSucceeded('Ordens de serviço', data);
}
}