Breezejs ZUMO示例将inlineCount返回为未定义

Breezejs ZUMO示例将inlineCount返回为未定义,breeze,azure-mobile-services,Breeze,Azure Mobile Services,我试图从breeze查询中获取inlinecount。结果将返回,但inlineCount属性将未定义。我在Fiddler中捕获了breeze查询和结果,它们似乎是正确的。服务器返回Fiddler中的值,并在json结果中添加count属性。我用自己的应用程序得到了同样的结果 // Get all TodoItems from the server and cache combined function getAllTodoItems() { // Create

我试图从breeze查询中获取inlinecount。结果将返回,但inlineCount属性将未定义。我在Fiddler中捕获了breeze查询和结果,它们似乎是正确的。服务器返回Fiddler中的值,并在json结果中添加count属性。我用自己的应用程序得到了同样的结果

   // Get all TodoItems from the server and cache combined
    function getAllTodoItems() {

        // Create the query
        var query = breeze.EntityQuery.from('TodoItem')
       .inlineCount();


        // Execute the query
        return manager.executeQuery(query)
            .then(success).catch(queryFailed);

        function success(data){
            // Interested in what server has then we are done.
            var fetched = data.results;
            $log.log('breeze query succeeded. fetched: '+ fetched.length);

            // Blended results.
            // This gets me all local changes and what the server game me.
            return manager.getEntities(todoItemType);

            // Normally would re-query the cache to combine cached and fetched
            // but need the deleted entities too for this UI.
            // For demo, we returned every cached Todo
            // Warning: the cache will accumulate entities that
            // have been deleted by other users until it is entirely rebuilt via 'refresh'
        }
    }

如果使用
BreezeQueryableAttribute
装饰WebApi Get方法,或者使用
BreezeControllerAttribute
装饰WebApi控制器,Breeze将添加
inlineCount
属性。否则,您可以通过调用
data.httpResponse.data.count
来获取计数

您可以在todo示例中通过启动WebApi服务器并在config.js文件中将
uzeZumo
变量设置为false来证明这一点。这将从WebApi获取记录。默认情况下,它将从Zumo获取数据


希望这有帮助。

谢谢Denis,我正在开发一个移动应用程序,这样我就不会有ASP.NET Web API后端了。我认为data.results.length将为我提供查询返回的项目计数,而不是远程存储中的所有项目计数。当我将.inlineCount()添加到查询中时,breeze生成的查询是正确的。当我在Fiddler中检查它时,它返回查询的项目和项目总数。有什么想法吗?你是对的。对不起,误传了。我已经编辑了我的回复。谢谢。这得到了我想要的结果。