Exemplo n.º 1
0
        /// <summary>
        /// ArticleId をもとに関連するコメントの一覧を取得する
        /// </summary>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public IEnumerable <CommentViewModel> RetrieveCommentList(int articleId)
        {
            var query = from c in _repository.Comments
                        where c.ArticleID == articleId
                        select c;

            List <CommentViewModel> models = new List <CommentViewModel>();

            foreach (var comment in query)
            {
                CommentViewModel model = new CommentViewModel();
                model.InjectFrom(comment);
                models.Add(model);
            }
            return(models);
        }