private void ConvertToModelOther(IDataReader reader, accountOther model) { if (reader["id"] != DBNull.Value) model.Id = Convert.ToInt32(reader["id"]); if (reader["RealName"] != DBNull.Value) model.RealName = Convert.ToString(reader["RealName"]); if (reader["TeacherNo"] != DBNull.Value) model.TeacherNo = Convert.ToString(reader["TeacherNo"]); if (reader["RegionId"] != DBNull.Value) model.RegionId = Convert.ToInt32(reader["RegionId"]); if (reader["RegionTitle"] != DBNull.Value) model.RegionTitle = Convert.ToString(reader["RegionTitle"]); if (reader["OrganId"] != DBNull.Value) model.OrganId = Convert.ToInt32(reader["OrganId"]); if (reader["OrganTitle"] != DBNull.Value) model.OrganTitle = Convert.ToString(reader["OrganTitle"]); if (reader["DiscussCnt"] != DBNull.Value) model.DiscussCnt = Convert.ToInt32(reader["DiscussCnt"]); }
/// <summary> /// 获取分页数据集 /// </summary> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="where"></param> /// <param name="orderBy"></param> /// <param name="recordCount"></param> /// <returns></returns> public List<accountOther> GetListOther(int pageSize, int pageIndex, string where, out int recordCount) { recordCount = GetListOtherCount(where); int start = (pageIndex - 1) * pageSize + 1; int end = pageIndex * pageSize; StringBuilder sql = new StringBuilder(); sql.Append(" select * from (select *,ROW_NUMBER() over (order by id) as [RowNum] from "); sql.Append(" (select distinct * from(select MA.id as accountid,MA.OutSourceId as id,(case when MB.RealName is null then MA.UserName else MB.RealName end) as RealName, MB.TeacherNo, ODR.id as RegionId,ODR.Title as RegionTitle, ODO.id as OrganId,ODO.Title as OrganTitle, "); sql.Append(" (select COUNT(1) from " + StatisticDataName + ".dbo.V_account where userid = MA.OutSourceId) as DiscussCnt "); sql.Append(" from dbo.Member_Account MA "); sql.Append(" LEFT JOIN dbo.Member_BaseInfo MB ON MA.Id = MB.AccountId AND MB.Delflag = 0"); sql.Append(" LEFT JOIN dbo.Organ_Detail ODR ON MB.RegionId = ODR.Id AND ODR.Delflag = 0"); sql.Append(" LEFT JOIN dbo.Organ_Detail ODO ON MB.OrganId = ODO.Id AND ODO.Delflag = 0 WHERE mb.Delflag=0 and ma.delflag=0 and ma.OutSourceId is not null and ma.OutSourceId <>0) as Tab "); if (!string.IsNullOrEmpty(where)) sql.Append(" where " + where); sql.Append(") as T) as TT where [RowNum] between " + start + " and " + end); sql.Append(" ORDER BY id"); List<accountOther> list = new List<accountOther>(); using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString())) { while (reader.Read()) { accountOther model = new accountOther(); ConvertToModelOther(reader, model); list.Add(model); } } return list; }