开发者

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

开发者 https://www.devze.com 2023-02-03 22:54 出处:网络
I have a table Orders like this: ID CustomerID name ID CustomerID name 14aa 56bbb开发者_如何转开发 49ccc

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

精彩评论

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