This project is read-only.

RunSelect with only paging

Jun 29, 2011 at 4:32 PM

I need to present all the records from an SQL table with paging.

The only method i know of for selection from the DAL with paging is:

qwertyCollection.RunSelect (linqWhereCondition, pagingDefinition);

Only that method doesn't have any overload that accepts only the pagingDefinition. Therefore i am currently using the overload of (linqWhereCondition, pagingDefinition) with a «fake» linq statement:

qwertyCollection.RunSelect (x => ==, pagingDefinition);
I feel i could be doing something better. Is there some way to select unconditionaly with paging? If this is the only way, is there a better linq statement i could use (null or something else)?

(i am using the nHydrate DAL)

Jun 29, 2011 at 5:57 PM

Paging is built in. You define a paging object and send it into the RunSelect method. Below I have a collection of OrderBundle objects. Notice how I query and then set my paging control with the property number of total records that is returned from the query,

var paging = new OrderBundlePaging(PagingControl1.PageIndex, PagingControl1.RecordsPerPage, OrderBundle.FieldNameConstants.Name, true);
var orderBundleCollection = OrderBundleCollection.RunSelect(x => true, paging);
PagingControl1.ItemCount = paging.RecordCount;
grdItem.DataSource = orderBundleCollection;

Jun 30, 2011 at 10:32 AM

Ok, so i can use the following linq query, which is nice:

x => true

Still, i think that there should be an overload of the method .RunSelect() that accepted paging without requiring the where conditions. But since the focus of nHydrate is on the new format EF-DAL, it would be kind of pointless to be worrying about that because there is a solution.


I didn't knew that the paging would also return me the .RecordCount, which is quite nice. I was doing entityCollection.GetCount() to get that value.



Jul 1, 2011 at 8:19 PM

The paging functionality is very nice. This is something that data frameworks should have done years ago. It is difficult to get this information in an easy to call manner. Just use the lambda above to query with no criteria.