Esempio n. 1
0
        public static void Add(List <TeamRecord> teamRecords)
        {
            using (var db = new FFStatsDbContext())
            {
                db.TeamRecords.AddRange(teamRecords);

                // the call to AddRange above will set Team in TeamRecord as added,
                // but since they already exist in the database we need to detach them
                foreach (var teamRecord in teamRecords)
                {
                    if (teamRecord.Team != null)
                    {
                        db.Entry(teamRecord.Team).State = EntityState.Detached;
                    }
                }

                db.SaveChanges();
            }
        }
Esempio n. 2
0
        public static void Add(List <RosterEntry> entries)
        {
            using (var db = new FFStatsDbContext())
            {
                db.RosterEntries.AddRange(entries);

                // the call to AddRange above will set Player in RosterEntry as added,
                // but since they already exist in the database we need to detach them
                foreach (var entry in entries)
                {
                    if (entry.Player != null)
                    {
                        db.Entry(entry.Player).State = EntityState.Detached;
                    }
                }

                db.SaveChanges();
            }
        }