The GetAll()
methods mentioned earlier are very useful, but what if we only want a subset of those records? For example, what if we want the first 25 instances, then the next 25, and so on? This happens a lot in ASP.NET applications when we want to return paginated data 25 records at a time, instead of an entire list of 5,000 records.
In order to make this work, we simply need to tell the criteria what record to start returning from, and how many records to return. With one more variable, SortExpression
, we can tell it to sort the records also, so that paging and sorting can be added to our data-bound controls such as the gridview.
To make this work, we need to pass in an integer for firstResult
to return, a second integer for the maxResults
to return, and a string for the sortExpression
.
When ASP.NET passes the sort criteria, it is in the form "SORT_FIELD" or "SORT_FIELD<space>DESC". We need to split this field on the space, and if the second field...