我正在使用此代码从db获取记录:
use db = new dbml.MobileDataContext(connectionString)
query {
for rows in db.Item do
where (
(orgid1 = "0" || rows.OrgId1 = orgid1)
)
select rows
} |> (fun s ->
if Seq.isEmpty s then
[||]
else
s
|> Seq.skip offset |> Seq.take (int chunk)
|> Seq.map sql.Record2Item |> Seq.toArray)
但是,如果我查看SQL Profiler中的查询,我会看到LINQ将所有记录返回给客户端并获取客户端上的记录子集。
但我需要让SQL查询看起来像:
... OFFSET " + offset + " ROW FETCH NEXT " + chunk + " ROWS ONLY"
是否可以在服务器端上使用分页?
答案 0 :(得分:1)
我找到了解决方案:
query {
for rows in db.Item do
select rows
skip offset
take chunk
}