LINQ to SQL Every Nth Row From Table

前端 未结 6 1555
情歌与酒
情歌与酒 2020-12-09 17:30

Anybody know how to write a LINQ to SQL statement to return every nth row from a table? I\'m needing to get the title of the item at the top of each page in a paged data gr

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 18:28

    There really doesn't seem to be an easy way to do this:

    How do I add ROW_NUMBER to a LINQ query or Entity?

    How to find the ROW_NUMBER() of a row with Linq to SQL

    But there's always:

    peopleToFilter.AsEnumerable().Where((x,i) => i % AmountToSkipBy == 0)
    

    NOTE: This still doesn't execute on the database side of things!

提交回复
热议问题