Exemplo n.º 1
0
        public void RemoveAll()
        {
            foreach (var item in _context.Players)
            {
                _context.Players.Remove(item);
            }

            _context.SaveChanges();
        }
Exemplo n.º 2
0
        public void RemoveAll()
        {
            var matches = _context.Matches
                          .Include(m => m.MatchesPlayed)
                          .ThenInclude(mp => mp.Player1)
                          .Include(m => m.MatchesPlayed)
                          .ThenInclude(mp => mp.Player2)
                          .Include(m => m.MatchesPlayed)
                          .ThenInclude(mp => mp.Winner);

            foreach (var item in matches)
            {
                item.MatchesPlayed.Clear();
                _context.Matches.Remove(item);
            }

            _context.SaveChanges();
        }