Ejemplo n.º 1
0
        public ArticleViewModel GetArticleViewModel(int id)
        {
            var article = this.GetById(id);

            if (article != null)
            {
                ArticlesContext.Entry(article).Reference(a => a.Author).Load();
                ArticlesContext.Entry(article).Collection(a => a.Reviews).Load();
                return(article.MapToViewModel());
            }
            return(null);
        }
Ejemplo n.º 2
0
        public AuthorViewModel GetAuthorViewModel(int id)
        {
            Author author = this.GetById(id);

            if (author != null)
            {
                ArticlesContext.Entry(author).Collection(a => a.Articles).Load();
                ArticlesContext.Entry(author).Collection(a => a.Articles).Query().Select(q => q.Reviews).Load();
                return(author.MapToViewModel());
            }
            return(null);
        }