zoukankan      html  css  js  c++  java
  • EntityFrameWork分页

    EF分页代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _Default : System.Web.UI.Page
    {
        private int pageindex =int.Parse(HttpContext.Current.Request["page"].ToString());
        protected void Page_Load(object sender, EventArgs e)
        {
            DB_CSM_20150615Entities db = new DB_CSM_20150615Entities();
            var list = db.T_TASK.Where(u => u.TASK_ID != null);
    
            int recordCount = 0;
            recordCount = list.Count(); //获取总记录数要在skip前获取
            list=list.OrderBy(u=>u.TASK_ID);
            list = list.Skip(pageindex*10).Take(10); //跳过pageindex*10 取10条
    
           
            
            foreach (var v in list)
            {
                Response.Write(v.TASK_ID+"</br>");
            }
    
            Response.Write(recordCount);
     
           
        }
    }
  • 相关阅读:
    Linux常用操作命令总结
    Centos7安装FastDFS教程
    Permutation Sequence
    Next Permutation
    Remove Element
    4Sum
    3Sum Closest
    3Sum
    Longest Consecutive Sequence
    Median of Two Sorted Arrays
  • 原文地址:https://www.cnblogs.com/tiancai/p/4788911.html
Copyright © 2011-2022 走看看