private static void JoinClubAndTournament() { var ctJoin = new ClubTournament { ClubId = 1, TournamentId = 2 }; _context.AddRange(ctJoin); _context.SaveChanges(); }
public int AddMultipleClubs(string[] nameList) { var clubList = new List <Club>(); foreach (var name in nameList) { clubList.Add(new Club { ClubName = name }); } _context.Clubs.AddRange(clubList); var dbResult = _context.SaveChanges(); return(dbResult); }
private static void RemoveJoinBetweenClubAndTournament() { var join = new ClubTournament { ClubId = 1, TournamentId = 2 }; _context.Remove(join); _context.SaveChanges(); }
public static void InsertClub() { var club = new Club { ClubName = "Arsenal", City = "London", Founded = new DateTime(1886, 1, 1) }; _context.Clubs.Add(club); _context.SaveChanges(); }
public static void AddFootballerToExistingClubNotTracked(int clubId) { var club = _context.Clubs.Find(clubId); club.Footballers.Add(new Footballer { Name = "Piere-Emerick", Surname = "Aubameyang", ClubId = 1 }); using (var newContext = new FootballManagerContext()) { newContext.Clubs.Update(club); newContext.SaveChanges(); } }
public void CanInsertSamuraiIntoDatabase() { using (var context = new FootballManagerContext()) { context.Database.EnsureCreated(); var club = new Club(); context.Clubs.Add(club); Debug.WriteLine($"Before save: {club.Id}"); context.SaveChanges(); Debug.WriteLine($"After save: {club.Id}"); Assert.AreNotEqual(0, club.Id); } }
public void SaveChanges() { Context.SaveChanges(); }