コード例 #1
0
        private ArticleModel GetArticle(Guid articleId)
        {
            using (var context = new NewsContext())
            {
                var results = context
                              .Articles
                              .Where(x => x.Id == articleId)
                              .Select(x => ArticleQueryHandlersHelper.SetModel(x))
                              .FirstOrDefault();

                return(results);
            }
        }
コード例 #2
0
        private List <ArticleModel> GetArticlesByTag(Guid tagId)
        {
            using (var context = new NewsContext())
            {
                var results = context
                              .Articles
                              .Include(x => x.ArticleTags)
                              .Where(x => x.ArticleTags.Any(y => y.TagId == tagId))
                              .Select(x => ArticleQueryHandlersHelper.SetModel(x))
                              .ToList();

                return(results);
            }
        }