文章内容
2017/3/8 11:23:50,作 者: 黄兵
Linq to Sql中的Skip、Take
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | if (!string.IsNullOrEmpty(Info) && Info == "Topic") { var topicCount = blogsAll.Where(b => b.Topics == true).Include(b=>b.User).Include(b=>b.Comments); var topic = topicCount.OrderByDescending(b => b.CreationTime) .Skip(start) .Take(queryOptions.PageSize); //总页数 queryOptions.TotalPages = QueryOptionsCalculator.CalculateTotalPages(topicCount.Count(), queryOptions.PageSize); ViewBag.QueryOptions = queryOptions; var blogTopicList = topic.Select(b => new BlogViewModel { AuthorName = b.User.UserName, CommentsCount = b.Comments.Count, CreationTime = b.CreationTime, Id = b.Id, Overview = b.Body, Title = b.Title }).ToList(); ViewBag.blogTopicList = blogTopicList; return View(); } |
Skip表示从第几条数据开始,也就是说再这之前有多少条数据
Take的意思是显示多少条数据,也就相当于我们常用的pagesize
评论列表