Beispiel #1
0
        public IList<Core.Business.Answer> GetAllAnswer()
        {
            IList<Core.Business.Answer> answerlist = new List<Core.Business.Answer>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectAnswersAll");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Answer answer = new Core.Business.Answer();

                    if (!reader.IsDBNull(0)) answer.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) answer.QuestionsID = reader.GetGuid(1);
                    if (!reader.IsDBNull(2)) answer.Content = reader.GetString(2);
                    if (!reader.IsDBNull(3)) answer.ExpertID = reader.GetGuid(3);
                    if (!reader.IsDBNull(4)) answer.CreateDate = reader.GetDateTime(4);

                    answer.MarkOld();
                    answerlist.Add(answer);
                }
                reader.Close();
            }
            return answerlist;
        }
Beispiel #2
0
        public IList<Core.Business.Answer> SelectByQuestionId(Guid id)
        {
            IList<Core.Business.Answer> answerlist = new List<Core.Business.Answer>();
            SqlServerUtility sql = new SqlServerUtility();
            string sqlstr = "SELECT [Id],[questionsID],[Content],[ExpertID],[CreateDate] FROM [dbo].[Answer] WHERE [questionsID] = '" + id + "'";
            SqlDataReader reader = sql.ExecuteSqlReader(sqlstr);
            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Answer answer = new Core.Business.Answer();

                    if (!reader.IsDBNull(0)) answer.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) answer.QuestionsID = reader.GetGuid(1);
                    if (!reader.IsDBNull(2)) answer.Content = reader.GetString(2);
                    if (!reader.IsDBNull(3)) answer.ExpertID = reader.GetGuid(3);
                    if (!reader.IsDBNull(4)) answer.CreateDate = reader.GetDateTime(4);

                    answer.MarkOld();
                    answerlist.Add(answer);
                }
                reader.Close();
            }
            return answerlist;
        }