1.连接数据库
2.在Dal进行调用sql语句
public List<UserInfo> PageShow(out int totalcount,out int totalpage, string uname,int pageindex= 1,int pagesize =3) { SqlParameter[] sqls = { new SqlParameter("@pageindex",pageindex), new SqlParameter("@pagesize",pagesize), new SqlParameter("@uname",uname==null?"":uname), new SqlParameter("@totalcount",System.Data.SqlDbType.Int), new SqlParameter("@totalpage",System.Data.SqlDbType.Int) }; sqls[3].Direction = System.Data.ParameterDirection.Output; sqls[4].Direction = System.Data.ParameterDirection.Output; var list = db.Database.SqlQuery<UserInfo>("exec P_Show @pageindex,@pagesize,@uname,@totalcount out,@totalpage out", sqls).ToList(); totalcount = (int)sqls[3].Value; totalpage = (int)sqls[4].Value; return list; }