(Fully qualified class name: Datarabbit. Core. ipagermanager )
The datarabbit framework provides the function of paging the results of a single table query, which is the goal of ipagermanager. We can get ipagermanager reference from idataaccesser, the entry point of datarabbit:
PagerparametersParam =...; // construct paging Parameters
IpagermanagerPagermanager = Dataaccesser. getpagermanager ( Param );
First, let's look at the paging parameters.PagerparametersRequired information:
The paging parameters include:
Table -- indicates that the data table is paged.
Pagesize -- the size of each page, including the number of records.
Pkey -- indicates which primary key is used for sorting by page.
Wherestr -- indicates the query condition. Only the query results that meet the condition are displayed on the page. If you want to list all data in the table on the page, set it to its value null.
Cachersize -- indicates the maximum number of pages cached.
Fields -- indicates which columns are included in the page to return.
Fieldalias -- the alias of the column to be replaced.
By building Pagerparameters You can obtain the ipagermanager instance of the data page manager of the target table from idataaccesser. The ipagermanager interface is completely defined as follows: Public Interface Ipagermanager
{
/// <Summary>
/// Getpage retrieves the index page
/// </Summary>
DatatableGetpage ( Int Index );
/// <Summary>
///Itemcount total number of qualified records
/// </Summary>
IntItemcount {Get;}
//
// total pagecount pages
//
int pagecount { Get ;}
//
// cachersize cache size
//
int cachersize { Get ;}< BR >}
Through interface definition, we can see that ipagermanager does not inherit the itransactionaccesser interface, which indicates that ipagermanager can only work in a non-transaction environment.
The getpage () method obtains the content of the corresponding page based on the index of the page. Note that we use datatable to reflect the content of one page.
The following is an example of paging the student table and binding the page to the datagridview display: PagerparametersPara = New Pagerparameters ( " Student " , " ID " , "" , 10 );
IpagermanagerPagermanager = Dataaccesser. getpagermanager (para );
// Bind
This. Datagridview1.datasource=Pagermanager.Getpage(Int. Parse (This. Textbox_pageindex.text ));
Go to: datarabbit lightweight data access framework-Sequence