【发布时间】:2013-05-16 17:02:56
【问题描述】:
我的表由 3 列(sno、name、age)组成,现在我正在从数据库中检索带有额外列(行号)的表,我使用了以下代码
select * from (
select ROW_NUMBER() over (order by SNo asc)as rowindex,SNo,Name,Age
from tblExample)
as example where rowindex between ((pageindex*10)+1) and ((pageindex+1)*10)
注意:这里的 pageindex 是一个变量,它接受用户传递的一些整数值
我的数据库是 sql server 2008,现在我想使用 linq
编写相同的查询谁能把上面的sql查询改成linq。我无法做到这一点,因为我是 linq 的新手。我遇到了这个问题,请帮助我提前谢谢你
【问题讨论】:
-
类似 context.tlbExample.OrderBy(x => x.SNo).Skip(pageindex*10).Take(10).Select((i,x) => new { rowindex = i + pageindex*10 + 1, x.SNo, x.Name, x.Age})
标签: linq linq-to-sql