コード例 #1
0
        public WallViewModel GetPostsForUser(int userId)
        {
            WallViewModel result = new WallViewModel();

            result.Posts = context.Posts.Include(p => p.Author)
                           .Include(p => p.Comments)
                           .Include(p => p.ToUser)
                           .Where(p => p.ToUser != null)
                           .Where(p => p.ToUser.Id == userId)
                           .OrderByDescending(p => p.PublishedDate)
                           .Select(p => UserMapping.MapPostViewModelFromDb(p))
                           .ToList();

            return(result);
        }