开发者

Using Row_Number in Linq where clause

开发者 https://www.devze.com 2023-03-20 02:55 出处:网络
how can I simulate the following sql query using linq. I just want to have a Row_Number column and use it\'s values in linq where开发者_如何转开发 clause.

how can I simulate the following sql query using linq. I just want to have a Row_Number column and use it's values in linq where开发者_如何转开发 clause.

With t As (
    Select Row_Number() over ( Order by Id ) as 'RowId', * From Orders
) 
Select * From t Where RowId between 1 and 10


I think what you're trying to do is just Skip/Take, for paging.

So basically:

var result = dataContext.Products.Skip(0).Take(10).ToList();

(Code is untested, written off the top of my head)

0

精彩评论

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

关注公众号