开发者

How do I get the next record in table with linq?

I have a table Orders like this:

ID

CustomerID

name

ID CustomerID name 1 4 aa

5 6 bbb

开发者_如何转开发

4 9 ccc

8 10 ddd

first ordering the table,then get the next row..... How to do? if current row id is 4 ,i want to get the row where id==5


I think you want this:

Orders.OrderBy(x=>x.ID).Skip(1).Take(1)

Edit: If I understand your question now:

Orders.OrderBy(x=>x.ID).Where(x=>x.ID>4).FirstOrDefault();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜