Linq selecting range of records

前端 未结 3 1372
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 01:22
    var q = (from Comments in db.tblBlogComments where Comments.blogID == this.ID orderby Comments.date descending select new {
        Comments.userID, Comments.com         


        
3条回答
  •  孤城傲影
    2020-12-12 01:32

    int start = 10;
    int end = 20;
    var q = (from Comments in db.tblBlogComments 
                where Comments.blogID == this.ID 
                orderby Comments.date descending 
                select new {
                              Comments.userID, 
                              Comments.comment, 
                              Comments.date
                           }).Skip(start).Take(end - start);
    

    I'm not sure if Skip translates to SQL executed in the database, so this might be not so efficient.

提交回复
热议问题