Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MVC Newbie - Get Team Name Using ID in Another Table

Status
Not open for further replies.

XgrinderX

Programmer
Mar 27, 2001
225
0
0
US
I am creating a softball schedule app that will be used by multiple teams.

I have a table the has team info - id, name, coach, etc
I have a table that has game info - id, date, teamid, opponentid, outcome

Here are the two models:

Code:
namespace softball.Models
{
	[Table("tblTeams")]
	public class Team
	{
		[Key]
		public int iTeamID { get; set; }
		public string sTeamName { get; set; }
		public string sCoach { get; set; }
	}
}

Code:
namespace softball.Models
{
	[Table("tblSBgames")]
	public class Game
	{
		[Key]
		public int iGameID { get; set; }
		public int iTeamID { get; set; }
		public DateTime dtDate { get; set; }
		public int iOpponentID { get; set; }
		public byte? tiOutcome { get; set; }
	}
}

I know how to use LINQ to pass a model into my view that can return a list of games for a particular team, but of course it shows an ID number for the two teams involved and not the team names. How can I make it show the team names without resorting to doing data calls in the View itself?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top