【发布时间】:2013-12-14 00:49:45
【问题描述】:
在升级到针对 Web API 2 的微风 1.4.6 后,我相信在分页之后应用投影查询的内联计数。
例如,如果我指定 take(5),那么 inlinecount 会返回 5,即使过滤器匹配 100 条记录。
你能确认这是微风 1.4.6 的问题吗?
查看 QueryHelper 中的代码,似乎只有在修改 odata 查询以支持“嵌套”属性的“选择”等内容时才会发生这种情况。
我已经能够在失败的单元测试中重现该问题:
/*********************************************************
* inlineCount of projected paged products
*********************************************************/
test("inlineCount of projected paged products", 2, function () {
// Filtered query
var productQuery = EntityQuery.from("Products")
.where("ProductName", "startsWith", "C");
// Paging of that filtered query ... with inlineCount
var pagedQuery = productQuery
.select("ProductName, Category.CategoryName")
.orderBy("ProductName")
.skip(5)
.take(5)
.inlineCount();
var productCount, pagedCount, inlineCount;
var em = newEm();
stop(); // going async
// run both queries in parallel
var promiseProduct =
em.executeQuery(productQuery)
.then(function (data) {
productCount = data.results.length;
});
var promisePaged =
em.executeQuery(pagedQuery)
.then(function (data) {
pagedCount = data.results.length;
inlineCount = data.inlineCount;
});
Q.all([promiseProduct, promisePaged])
.then(function () {
ok(inlineCount,
"'data' from paged query should have 'inlineCount'");
equal(inlineCount, productCount,
"'inlineCount' should equal product count");
})
.fail(handleFail)
.fin(start);
});
非常欢迎修复 :-)
【问题讨论】:
标签: breeze