I need to output information from two tables
public class Team
{
[Key]
public int TeamId { get; set; }
public int TypeId { get; set; }
public string TeamName { get; set; }
}public class TeamType
{
[Key]
public int TypeId { get; set; }
public string TypeName { get; set; }
public virtual ICollection<Team> Teams { get; set; }
}
I build this class
public abstract class MyAppController : Controller
{
//
// GET: /MyApp/
private RenegadeEntities db = new RenegadeEntities();
public RenegadeEntities DataContext
{
get { return db; }
}
public MyAppController()
{
ViewBag.TeamList = db.TeamTypes.Include("Teams").ToList();
}
}
in view i do following:
@using Renegades.Helpers
@model IEnumerable<Renegades.Models.TeamType>
@foreach (var t in ViewBag.TeamList)
{
<li>
<span>@t.TypeName</span>
<ul id="sub_team_menu">
@foreach (var team in t.Team)
{
<li>team.TeamName</li>
}
</ul>
</li>
}
Please help me to understand how can i output data from two or more tables in my view