Open wis3guy opened 9 years ago
Sure, it's possible. Just curious: in what situations do you need an empty list?
F.ex when i want to return an empty search result. Sometimes i can already determine that a search is not going to yield any results without firing a query.
Or, f.ex. as a default values on my models. I always want my objects to be in a valid state, which means that in the default constructor i want to set my collection properties to an empty collection.
Alright, clear
Just looking at it, but I think it doesn't make any sense to create an empty constructor, because we'll have to assume some pagesize. Probably better to just use one of the existing constructors:
var emptyList = new PagedList<SomeType>(null, 0, 1);
The idea is not to create a mutable pagedlist, rather an immutable one which indicates no results.
On Sunday, October 5, 2014, Martijn Boland notifications@github.com wrote:
Just looking at it, but I think it doesn't make any sense to create an empty constructor, because we'll have to assume some pagesize. Probably better to just use one of the existing constructors:
var emptyList = new PagedList
(null, 0, 1); — Reply to this email directly or view it on GitHub https://github.com/martijnboland/MvcPaging/issues/44#issuecomment-57951905 .
Ciao, Geoffrey
Geoffrey Braaf | +31655793290 Freelance .NET Software Architect & Passionate Developer | http://wis3guy.net Findsi: find-as-i | http://www.findsi.com
Thanks for this tip wis3guy. It was indeed helpful.
Sometimes it is useful to be able to create an empty instance of PagedList. As i did not want to change the library, i worked around this by doing this:
and then using
it would be cleaner if i could simply do: