我们正在跟踪分页指南-https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/sort-filter-page?view=aspnetcore-2.1。
我们将页面大小设置为3进行测试,并在查询中返回54条记录。由于某些原因,var count = await source.CountAsync();在此下面返回为3?!?!有什么想法吗?
author_url
PaginatedList.cs类:
106422854611155436041
这是该index.cshtml的后端代码:
public static async Task<PaginatedList<T>> CreateAsync(
IQueryable<T> source, int pageIndex, int pageSize)
{
var count = await source.CountAsync();
var items = await source.Skip(
(pageIndex - 1) * pageSize)
.Take(pageSize).ToListAsync();
return new PaginatedList<T>(items, count, pageIndex, pageSize);
}
答案 0 :(得分:0)
实际上,我替换为:
>>> s =set()
>>> exact = 0
>>> exact_over = 0
>>> exact_under = 0
>>>for i in range(100):
... differ = (i - (i**0.5)**2)
... s |= {differ}
... exact += 1 if differ == 0 else 0
... exact_over += 1 if differ > 0 else 0
... exact_under += 1 if differ < 0 else 0
>>> sorted(list(s))
[-1.4210854715202004e-14,
-7.105427357601002e-15,
-3.552713678800501e-15,
-1.7763568394002505e-15,
-8.881784197001252e-16,
-4.440892098500626e-16,
0.0,
4.440892098500626e-16,
8.881784197001252e-16,
1.7763568394002505e-15,
3.552713678800501e-15,
7.105427357601002e-15,
1.4210854715202004e-14]
>>> exact_under, exact, exact_over
(26, 49, 25)
到
var count = await source.CountAsync();
这返回了正确的计数。