public List <dynamic> GetAllPersonalPic(PicManage picManage, PageModel pm) { StringBuilder sbSql = new StringBuilder(@"SELECT * FROM dbo.Image WHERE UserCode=@UserCode"); var dyParamter = new DynamicParameters(); dyParamter.Add("UserCode", picManage.UserCode); dyParamter.Add("PageIndex", pm.PageIndex); dyParamter.Add("PageSize", pm.PageSize); string querySql = string.Format("WITH query AS ({0}) ", sbSql); string countSql = querySql + " SELECT COUNT(*) FROM query"; using (var conn = AdoConfig.GetDBConnection()) { try { pm.TotalCount = conn.Query <int>(countSql, dyParamter).FirstOrDefault(); if (pm.TotalCount > 0) { string pageSql = querySql + " SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY IsDel ASC) AS RowNum, * FROM query ) t WHERE t.RowNum > (@PageIndex -1) * @PageSize AND t.RowNum <= @PageIndex * @PageSize"; return(conn.Query <dynamic>(pageSql, dyParamter).ToList()); } } catch (Exception ex) { new SendWarnningEMail().SendEMail(ex.ToString()); } return(new List <dynamic>()); } }
public ResultModel <List <dynamic> > GetAllPersonalPic(PicManage picManage, PageModel pm) { ResultModel <List <dynamic> > msg = new ResultModel <List <dynamic> >(); msg = new ResultModel <List <dynamic> >() { Data = new ImageDAL().GetAllPersonalPic(picManage, pm), PM = pm }; if (msg == null || msg.Data.Count == 0) { msg.Message = "暂无数据"; } return(msg); }