//查找单个问题,同时查找所有评论 public v.Question GetOne(string qId) { var sqlString = new StringBuilder(); try { var question = _service.SerarchList <Question>(string.Format("Id='{0}'", qId)); var comments = _service.SerarchList <Comment>(string.Format("QuestionId='{0}' and ParentId is null", qId)); var dt = SqlDBHelper.Query(sqlString.ToString()); v.Question q = new v.Question(); q.Comments = new List <v.Comment>(); question.ForEach(e => { q.Id = e.Id; q.Asker = e.Asker; q.AuditState = e.AuditState; q.Content = e.Content; q.CreateDate = e.CreateDate; }); comments.ForEach(e => { var c = new v.Comment(); c.Id = e.Id; c.ParentId = e.ParentId; c.QuestionId = e.QuestionId; c.Content = e.Content; c.Replayer = e.Replayer; c.CommentDate = e.CommentDate; }); return(q); } catch (Exception e) { e.WriterLog(); return(null); } }
//查找单个问题,同时查找所有评论 public v.Question GetOne(string qId) { var sqlString = new StringBuilder(); try { var question = _service.SerarchList<Question>(string.Format("Id='{0}'", qId)); var comments = _service.SerarchList<Comment>(string.Format("QuestionId='{0}' and ParentId is null", qId)); var dt = SqlDBHelper.Query(sqlString.ToString()); v.Question q = new v.Question(); q.Comments = new List<v.Comment>(); question.ForEach(e => { q.Id = e.Id; q.Asker = e.Asker; q.AuditState = e.AuditState; q.Content = e.Content; q.CreateDate = e.CreateDate; }); comments.ForEach(e => { var c = new v.Comment(); c.Id = e.Id; c.ParentId = e.ParentId; c.QuestionId = e.QuestionId; c.Content = e.Content; c.Replayer = e.Replayer; c.CommentDate = e.CommentDate; }); return q; } catch (Exception e) { e.WriterLog(); return null; } }