Dealing with a small number of items
See original GitHub issueHi,
I was trying out my project asp core 1.1 so I’m using 1.1.4 package… I found this bug:
If you put small number of items like this:
private void InitializeProducts()
{
for (var i = 0; i < 7; i++) // <=========== JUST 7 items
{
var product = new Product();
product.Name = "Product " + (i + 1);
var categoryIndex = i % 4;
if (categoryIndex > 2)
{
categoryIndex = categoryIndex - 3;
}
product.Category = allCategories[categoryIndex];
allProducts.Add(product);
}
}
It won’t show anything on the page and the list will be empty.
My controller action looks like this:
public IActionResult Index(int? page)
{
var currentPageNum = page.HasValue ? page.Value : 1;
var model = allProducts.ToPagedList(currentPageNum, 10);
return View(model);
}
*P.S: different kind of issue appears if you put 15 items.
Hope there is a fix (something like 1.1.5) for people who still use asp core 1.1.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Subitizing - Wikipedia
Subitizing is the rapid, accurate, and confident judgments of numbers performed for small numbers of items.
Read more >The (F)Law of Small Numbers and What to Do About It
How to Deal with Small Numbers · Suggestion #1: Reduce Reporting Frequency · Suggestion #2: Use a Simple Moving Average · Suggestion #3:...
Read more >Too Much Stuff, Not Enough Space? Try the 4-Box Technique
Do you have too much stuff and not enough space? Implement this straight-forward decluttering technique to get on top of the problem.
Read more >Dyscalculia: What It Is, Causes, Symptoms & Treatment
Identifying small quantities of items just by looking (this looks like needing to count each one by one). Doing simple calculations from memory....
Read more >Hoarding disorder
A hoarding disorder is where someone acquires an excessive number of items and stores them in a chaotic manner, usually resulting in unmanageable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The way I would do it is make your method GetAgentStudents return Paged Result of T of your model. ie pass in pagenumber and pagesize as params and only retrieve one page of data at a time from the db.
I reproduced it in the attachment. Pagination.zip
My actual code is projecting data then making a PagedList:
Where students is an IQueryable of StudentDetailsViewModel.
Do you suggest any other better approach?