The Liezi in the previous sections of the page have already appeared and are now being explained in detail.
There are three ways to achieve this:
1, top (int TopCount) method
In SQL Server and MSAccess in fact is top, in Oracle through ROWNUM implementation.
2, from (int startIndex, int endindex)
The number of records from the startindex bar to the Endindex bar.
3, Page (int pageSize, int pageIndex)
PageSize per page, page pageindex
These three methods are illustrated in turn below.
Top method:
DbSession.Default.From<Products>()
.Top(10)
.ToList();
The query is queried for the first 10 records in the Products table, and the resulting SQL statement is as follows: (How to output a view component-generated SQL)
Text:
SELECT Top * FROM [products]
From method:
DbSession.Default.From<Products>()
.From(3, 8)
.ToList();
Find data from Articles 3rd through 8th (including 3rd and 8th), and the resulting SQL statement is as follows:
Text:
SELECT * FROM
( SELECT TOP 6 * FROM
( SELECT TOP 8 * FROM [Products] ORDER BY [Products]. [ProductID] ASC)
AS tempIntable ORDER BY [ProductID] DESC)
AS tempOuttable ORDER BY [ProductID] ASC
Page Method:
DbSession.Default.From<Products>()
.Page(10, 2)
.ToList();