private void BtAddGender_Click(object sender, RoutedEventArgs e) { ApDBContext sqlContext = new MSSQLDBContext(); ApDBContext pgContext = new PostGreSQLDBContext(); if (sqlContext.Genders.Count() == 0 && pgContext.Genders.Count() == 0) { List <Gender> genders = new List <Gender>() { new Gender { Name = "Мужской" }, new Gender { Name = "Женский" } }; sqlContext.Genders.AddRange(genders); sqlContext.SaveChanges(); pgContext.Genders.AddRange(genders); pgContext.SaveChanges(); } else { MessageBox.Show("Уже добавлены в бд"); } }
private void BtPg_Click(object sender, RoutedEventArgs e) { ApDBContext pgContext = new PostGreSQLDBContext(); pgContext.Users.Add(NewUserGenerator()); pgContext.SaveChanges(); dgPostgreSql.ItemsSource = pgContext.Users.ToList(); }
private void BtPgSqlClear_Click(object sender, RoutedEventArgs e) { ApDBContext pgContext = new PostGreSQLDBContext(); pgContext.Users.RemoveRange(pgContext.Users); pgContext.SaveChanges(); dgPostgreSql.ItemsSource = pgContext.Users.ToList(); }