Beispiel #1
0
 //--------------------------------------------------------------------------------------------------------------
 public List <Team> GetAllTeams()
 {
     using (TeamsContext context = new TeamsContext())
     {
         return(context.Teams.Include(t => t.TeamType)
                .Include(t => t.Players)
                .AsNoTracking().ToList());
     }
 }
Beispiel #2
0
 //--------------------------------------------------------------------------------------------------------------
 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));
     }
 }
Beispiel #3
0
        //--------------------------------------------------------------------------------------------------------------
        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();
            }
        }