How to implement SkipWhile with Linq to Sql without first loading the whole list into memory?

前端 未结 3 1045
天命终不由人
天命终不由人 2021-01-17 12:05

I need to order the articles stored in a database by descending publication date and then take the first 20 records after the article with Id == 100.

T

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 12:51

    Isnt the solution to just add a where statement?

    IQueryable
    articles = db.Articles.Where(a => a.id != 100).OrderByDescending(a => a.PublicationDate).Take(20);

提交回复
热议问题