Hello Everyone,
 I am facing a problem presently with a query that uses the id parameter in the query string to fetch a single post from the database and also retrieve all comments that belong to the posts. So far i know that i want a single post hence my view will not contain the IEnumerable interface because in my query i use .single(). However since i'm fetching a list of comments from the database and not just one comment i know that will be IEnumerable. My problem is how to combine both interfaces so that i can display that single post and all comments that belong to it . 

```
 public class ReadPostsVM
{
    public string PostTitle { get; set; }

    public string PostContent { get; set; }

    public string PostAuthor { get; set; }

    public DateTime PostDate { get; set; }

    public string Comment { get; set; }

    public string CommentAuthor { get; set; }

    public DateTime CommentDate { get; set; }

}

```

This is what i tried in the controller

```
public ActionResult ReadPost(int id)
{
    var query = from p in db.Posts.Where(p => p.PostId == id)
                from c in db.Replies.Where(c => c.PostId == id)
                join u in db.UserProfiles
                on p.AuthorId equals u.UserId
                where p.PostId == id
                select new ReadPostsVM()
                {
                    PostTitle = p.PostTitle,
                    PostContent = p.PostContent,
                    PostDate = p.DateCreated,
                    PostAuthor = u.UserName,
                    Comment = c.Reply1,
                    CommentAuthor = u.UserName,
                    CommentDate = c.ReplyDate
                };

    var query = from p in db.Posts
                join u in db.UserProfiles
                on p.AuthorId equals u.UserId
                where p.PostId == id
                select new ReadPostsVM()
                {
                    PostTitle = p.PostTitle,
                    PostContent = p.PostContent,
                    PostDate = p.DateCreated,
                    PostAuthor = u.UserName,

                };

    return View(query.Single());

}

```

However in the view i have 

```
@model IEnumerable<Blogger.ViewModels.ReadPostsVM>

```

and a foreach loop which gave me an error saying

```
Sequence does not contain any element

```

Another option i think i have is to fetch just this below

```
public ActionResult ReadPost(int id)
    {

        var query = from p in db.Posts
                    join u in db.UserProfiles
                    on p.AuthorId equals u.UserId
                    where p.PostId == id
                    select new ReadPostsVM()
                    {
                        PostTitle = p.PostTitle,
                        PostContent = p.PostContent,
                        PostDate = p.DateCreated,
                        PostAuthor = u.UserName,

                    };

        return View(query.Single());

    }

```

to get that single post using to return just a single post and maybe i can then use a Partial view to display the comments. 

```
@model Blogger.ViewModels.ReadPostsVM

```

Please help me out how can I achieve this aim. If i am to use a partial view how can i make that partial view to fetch comments based on the parameter in the url since i will have to invoke an action with an id parameter but i dont have any link pointing to that page and also i dont think it would make sense like that. I hope my question makes sense? Please help!

To show the relationship between the Posts entity and the comments entity i have added the Posts.cs class and Replies.cs class below

```
public partial class Post
{
    public Post()
    {
        this.Replies = new HashSet<Reply>();
    }

    public int PostId { get; set; }
    public string PostTitle { get; set; }
    public string PostContent { get; set; }
    public int AuthorId { get; set; }
    public int CategoryId { get; set; }
    public System.DateTime DateCreated { get; set; }

    public virtual Category Category { get; set; }
    public virtual UserProfile UserProfile { get; set; }
    public virtual ICollection<Reply> Replies { get; set; }
}

 public partial class Reply
    {
        public int ReplyId { get; set; }
        public string Reply1 { get; set; }
        public System.DateTime ReplyDate { get; set; }
        public int AuthorId { get; set; }
        public int PostId { get; set; }
        public int CategoryId { get; set; }

        public virtual Category Category { get; set; }
        public virtual Post Post { get; set; }
        public virtual UserProfile UserProfile { get; set; }
    }

```