Пример #1
0
 public List <Studenti> GetAllStudents()
 {
     using (PassDBEntities db = new PassDBEntities())
     {
         return(db.Studenti.ToList());
     }
 }
Пример #2
0
 public void InserareStudent(Studenti student)
 {
     //EF Code
     using (PassDBEntities db = new PassDBEntities())
     {
         db.Studenti.Add(student);
         db.SaveChanges();
     }
 }
Пример #3
0
 public void ActualizeazaStudent(Studenti student)
 {
     //EF Code
     using (PassDBEntities db = new PassDBEntities())
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #4
0
 public void StergereStudent(Studenti student)
 {
     //EF COde
     using (PassDBEntities db = new PassDBEntities())
     {
         var entry = db.Entry(student);
         if (entry.State == EntityState.Detached)
         {
             db.Studenti.Attach(student);
         }
         db.Studenti.Remove(student);
         db.SaveChanges();
     }
 }