1
votes

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);
        }
    }
2
Can't repro this one yet. All of our test cases with inlineCount and EF6 seem to be working properly. But will keep looking.Jay Traband
Can you post a specify 'simple' query that fails with both the client side query logic and the server endpoint logic?Jay Traband
Includes a way to get the behavior in the above.julianpaulozzi
Ok, thx. This is a regression. It will be fixed in the next release, out either over the weekend or Monday.Jay Traband
Thanks for listening, post here when ok so I can mark as solved.julianpaulozzi

2 Answers

0
votes

This has been fixed in the latest release: Breeze 1.4.7, available now.

0
votes

Had the similar problem with EF5, as asked here: Breeze inlineCount is undefined

Adding attributes to methods used to break inlineCount for me. After a while, I figured for those queries that require pagination, it's usually just minimum of information from entity represented so I rewrote those queries to include only partial data and wrote down inlineCount by myself and it works fine.