LINQ statement that returns rownumber of element with id == something?

前端 未结 3 1111
-上瘾入骨i
-上瘾入骨i 2021-02-20 09:15

How to write LINQ statement that returns ROWNUMBER of element with id == something?

3条回答
  •  抹茶落季
    2021-02-20 10:13

    You should be able to use the Skip and Take extension methods to accomplish this.

    For example, if you want row 10:

    from c in customers
               where c.Region == "somewhere"
               orderby c.CustomerName
               select new {c.CustomerID, c.CustomerName} 
               .Skip(9).Take(1);
    

提交回复
热议问题