Click here to Skip to main content
14,107,154 members
Rate this:
Please Sign up or sign in to vote.
I want to show records of multiple table in a single view using entity framework database first approach.

this is my controller class:

What I have tried:

     public ActionResult Index()
        var query = (from c in db.tblBlogs
                     join d in db.tblBlogComments on equals d.BlogId
                     join e in
                   db.tblBlogLikes on equals e.BlogId
                     join f in db.tblBlogMedias on equals f.BlogId
                     where == d.BlogId || == e.BlogId || == 
                     select c).OrderByDescending(d => 

            return View(query);

This is Index.cshtml file :
@media ICollection<MVCProject.Models.tblBlog>

     @foreach(var item in Model)
        { <h1>@item.BlogPicture</h1>

here BlogPicture is in table tblBlogMedia
Title & description is in tblBlogs

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190518.1 | Last Updated 25 Mar 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100