示例#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;
        }
示例#2
0
        public Core.Business.Answer Select(Guid id)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Id", SqlDbType.UniqueIdentifier, id);
            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectAnswer");

            if (reader != null && !reader.IsClosed && 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);

                reader.Close();
                return answer;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
示例#3
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;
        }