Paging
Old forum URL: forums.lhotka.net/forums/t/1658.aspx
PDC posted on Wednesday, November 01, 2006
Hi
Are there any examples of how to do paging using CSLA?
Will
Bayu replied on Wednesday, November 01, 2006
You have 2 choices:
- hit the DB for every page, then at least you should modify your Criteria class so you specify the offset and limit for your SQL query.
- or hit the DB once to retrieve the whole bunch and paginate this set in your control, then it is strictly a UI thing and you would have to tune your Grid control so it pages through your data.
Usually the latter is recommended, unless you have really big resultsets.
Bayu
PDC replied on Wednesday, November 01, 2006
Maybe I should be a bit more specific. The change log for v2.1 states this about the CslaDataSource
Implement support for paged and sorted data sources. There are now properties on the control so you can indicate whether the underlying data source supports paging or sorting. This way, if you bind to a SortedBindingList, for instance, you can indicate that the data source supports sorting to expose sorting support at a higher level.
Coupled with the new IReportTotalRowCount interface, the ability to indicate that a data source supports paging provides a relatively easy way to create a paged list that works property when bound to a grid control.
Does this mean that all I have to do, once I have changed my db calls, is to set the property on the CslaDataSource and the grid control will do the rest?
xAvailx replied on Wednesday, November 01, 2006
Bayu: You have 2 choices:
- hit the DB for every page, then at least you should modify your Criteria class so you specify the offset and limit for your SQL query.
- or hit the DB once to retrieve the whole bunch and paginate this set in your control, then it is strictly a UI thing and you would have to tune your Grid control so it pages through your data.
Usually the latter is recommended, unless you have really big resultsets.
Bayu
I am not sure I would ever recommend the second choice in a web environment. Assuming you are saying retrieve the entire data set and persist in session or some other means between postbacks. Would you agree?
Bayu replied on Thursday, November 02, 2006
You are right xAvailx! I have been working with WinForms apps for so long I start to assume everybody does ...
Sorry for misleading you .... my suggestion is only applicable for WinForms. In web apps you have to be more careful.
However, the original question of this thread remains unanswered .... and I'm afraid I have no experience with paging in the way suggested.
Bayu
Copyright (c) Marimer LLC