asp.net mvc Join two tables to a single list item in html unordered list

asp.net asp.net-mvc-5 entity-framework entity-framework-6 join

Question

I've successfully combined two tables into a single html unordered list using a sql inner join with two tables in webforms.

I'm utilizing Entity Framework 6 and Asp.net MVC 5.

To once again output a single html unordered list, I'm attempting to link the same two tables in MVC.

Team is the name of the first table, and id is the column The teamID column can be found in the second table, teamgallery. Team.id and teamgallery.teamID have the same values.

utilizing the controller

dynamic dmodel = new ExpandoObject();
dmodel.Teamre = (from pd in db.teams
                join od in db.teamgalleries on pd.id equals od.teamID
                where pd.Catresales == "yes"
                select new 
                {
                    pd.id,
                    pd.name,
                    od.picture
                 }).ToList();
return View(dmodel);

In the opinion

<ul>
    @foreach (var teamre in Model.Teamre)
    {
        <li>
            @teamre
        </li>
    }
</ul>

This produces a list similar to this one in the web browser:

Id = 1, John Doe is the name, and picture 1.jpg is the image.

Id = 2, Jane Doe is the name, and picture2 is a jpg.

If I modify the razor code to only show the names, then:

@teamre.name

I will experience this error

'object' does not contain a definition for 'name,' leading to a server error in the 'application'

Even if I type, the mistake still appears.

name = pd.name, 
1
0
9/8/2015 12:41:09 PM

Accepted Answer

ZZZ_tmp
0
9/13/2015 9:54:29 PM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow