public IList<Question> GetSqlWhere(string sqlwhere) { IList<Core.Business.Question> questionlist = new List<Core.Business.Question>(); SqlServerUtility sql = new SqlServerUtility(); StringBuilder sbOrderExpression = new StringBuilder(); sbOrderExpression.Append(string.Format("CreateDate desc")); sql.AddParameter("@WhereCondition", SqlDbType.NVarChar, sqlwhere); sql.AddParameter("@OrderByExpression", SqlDbType.NVarChar, sbOrderExpression.ToString()); SqlDataReader reader = sql.ExecuteSPReader("usp_SelectQuestionsDynamic"); if (reader != null) { while (reader.Read()) { Core.Business.Question question = new Core.Business.Question(); if (!reader.IsDBNull(0)) question.Id = reader.GetGuid(0); if (!reader.IsDBNull(1)) question.Title = reader.GetString(1); if (!reader.IsDBNull(2)) question.Content = reader.GetString(2); if (!reader.IsDBNull(3)) question.UserID = reader.GetGuid(3); if (!reader.IsDBNull(4)) question.CreateDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) question.IsHomePage = reader.GetInt32(5); question.MarkOld(); questionlist.Add(question); } reader.Close(); } return questionlist; }
public IList<Core.Business.Question> GetAllQuestion() { IList<Core.Business.Question> questionlist = new List<Core.Business.Question>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader = sql.ExecuteSPReader("usp_SelectQuestionsAll"); if (reader != null) { while (reader.Read()) { Core.Business.Question question = new Core.Business.Question(); if (!reader.IsDBNull(0)) question.Id = reader.GetGuid(0); if (!reader.IsDBNull(1)) question.Title = reader.GetString(1); if (!reader.IsDBNull(2)) question.Content = reader.GetString(2); if (!reader.IsDBNull(3)) question.UserID = reader.GetGuid(3); if (!reader.IsDBNull(4)) question.CreateDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) question.IsHomePage = reader.GetInt32(5); // question.User = CY.CSTS.Core.Business.User.Load(question.UserID); question.MarkOld(); questionlist.Add(question); } reader.Close(); } return questionlist; }