LINQ
分页查询

分页查询

⚠️

该文档可能已过期。

  • SelectPage:查询结果分页或执行分页查询。(分页参数从第 1 页开始)

例如,查询雇员(Employees)表,按每页 2 条记录分页,选择第 3 页的记录返回:

EmployeeIDAddressCity
1507 - 20th Ave. E. Apt. 2ASeattle
2908 W. Capital WayTacoma
3722 Moss Bay Blvd.Kirkland
44110 Old Redmond Rd.Redmond
514 Garrett HillLondon
6Coventry House Miner Rd.London
7Edgeham Hollow Winchester WayLondon
84726 - 11th Ave. N.E.Seattle
97 Houndstooth Rd.London
var query = sqlite.Employees
    .SelectPage(pageNumber: 3, pageSize: 2);
var result = query.Select(x => new
{
    x.EmployeeID,
    x.Address,
    x.City,
}).ToArray();

生成 SQL:

SELECT *
FROM "Employees" AS "e"
ORDER BY (SELECT 1)
LIMIT 2 OFFSET 4;

运行结果:

EmployeeIDAddressCity
514 Garrett HillLondon
6Coventry House Miner Rd.London