//-------------------------------------------------------------------------------------------------------------- public List <Team> GetAllTeams() { using (TeamsContext context = new TeamsContext()) { return(context.Teams.Include(t => t.TeamType) .Include(t => t.Players) .AsNoTracking().ToList()); } }
//-------------------------------------------------------------------------------------------------------------- public Team GetTeamByID(int ID) { using (TeamsContext context = new TeamsContext()) { //context.Configuration.ProxyCreationEnabled = false; return(context.Teams.Include(t => t.TeamType) .Include(t => t.Players) .AsNoTracking() .SingleOrDefault(t => t.ID == ID)); } }
//-------------------------------------------------------------------------------------------------------------- public void InsertTeam(string teamName, string teamHome, int teamTypeID) { Team newTeam = new Team { Name = teamName, Home = teamHome, TeamTypeID = teamTypeID }; using (TeamsContext context = new TeamsContext()) { context.Teams.Add(newTeam); context.SaveChanges(); } }