//查找问题列表 public List <Question> GetQuestions(int page, int size) { var sqlString = new StringBuilder(); sqlString.AppendFormat("select top {0} q.Id as qId,q.Content as qContent,q.Asker as qAsker,q.AuditState as qAuditState,q.CreateDate as qCreateDate from Question q ", size); sqlString.AppendFormat("where q.Id not in(select top {1} Id from Question order by CreateDate desc) ", (page - 1) * size); sqlString.Append("order by CreateDate desc "); var qList = new List <Question>(); try { using (var dataReader = SqlDBHelper.ExecuteReader(sqlString.ToString())) { while (dataReader.Read()) { var q = new Question { Id = dataReader["qId"].ToSafeTrim(), Asker = dataReader["qAsker"].ToSafeTrim(), Content = dataReader["qContent"].ToSafeTrim(), CreateDate = dataReader["qCreateDate"].ToSafeTrim() }; qList.Add(q); } } return(qList); } catch (Exception e) { e.WriterLog(); return(null); } }
public List <Model.Comment> GetComments() { var sqlString = new StringBuilder(); sqlString.Append("with tb as "); sqlString.Append("( "); sqlString.AppendFormat("select t1.* from Comment t1 where t1.ParentId='{0}' ", this.ParentId); sqlString.Append(" "); sqlString.Append("union all "); sqlString.Append(" "); sqlString.Append("select t2.* from Comment t2 inner join tb "); sqlString.Append("on t2.ID=tb.PID) "); sqlString.Append("select * from tb "); var list = new List <Model.Comment>(); try { using (var dataReader = SqlDBHelper.ExecuteReader(sqlString.ToString())) { while (dataReader.Read()) { var commnet = new Model.Comment { Id = dataReader["Id"].ToString(), ParentId = dataReader["ParentId"].ToString(), Replayer = dataReader["Replayer"].ToString(), CommentDate = dataReader["CommnetDate"].ToString(), Content = dataReader["Content"].ToString(), QuestionId = dataReader["QuestionId"].ToString() }; list.Add(commnet); } } return(list); } catch { return(null); } }
public MainSkill EditMainSkill(int id) { MainSkill mainSkill = new MainSkill(); try { object[] param = { id }; SqlDataReader dataReader = SqlDBHelper.ExecuteReader(_connection, StoredProcedures.sp_GetMainSkill, param); if (dataReader.Read()) { mainSkill.Id = (int)dataReader["Id"]; mainSkill.MainSkillName = dataReader["SkillName"].ToString(); mainSkill.MainSkillDesctiption = dataReader["SkillDescription"].ToString(); mainSkill.Active = (bool)dataReader["Active"]; } } catch (Exception ex) { } return(mainSkill); }