コード例 #1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     using (var db = new TanarokDBEntities())
     {
         dg_adat.ItemsSource = db.Tanar.ToList();
     }
 }
コード例 #2
0
        private void btn_add_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new TanarokDBEntities())
            {
                var tanaradat = new Tanar()
                {
                    Nev       = tb_nev.Text,
                    Varos     = tb_lakhely.Text,
                    Vegzetseg = tb_vegzetseg.Text,
                    Neme      = tb_nem.Text,
                };

                db.Tanar.Add(tanaradat);
                db.SaveChanges();
                dg_adat.ItemsSource = db.Tanar.ToList();
            }
        }