EF调用sql语句
作者:互联网
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; }
标签:语句,totalpage,sqls,int,EF,uname,sql,new,SqlParameter 来源: https://www.cnblogs.com/JWKK/p/15154293.html