コード例 #1
0
ファイル: TeamRepository.cs プロジェクト: AndrewSMoroz/Teams
 //--------------------------------------------------------------------------------------------------------------
 public List <Team> GetAllTeams()
 {
     using (TeamsContext context = new TeamsContext())
     {
         return(context.Teams.Include(t => t.TeamType)
                .Include(t => t.Players)
                .AsNoTracking().ToList());
     }
 }
コード例 #2
0
ファイル: TeamRepository.cs プロジェクト: AndrewSMoroz/Teams
 //--------------------------------------------------------------------------------------------------------------
 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));
     }
 }
コード例 #3
0
ファイル: TeamRepository.cs プロジェクト: AndrewSMoroz/Teams
        //--------------------------------------------------------------------------------------------------------------
        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();
            }
        }