Exemple #1
0
 public void Update(Person person)
 {
     using (var db = new ContosoDBContext())
     {
         db.Person.Attach(person);
         db.Entry(person).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void Delete(Course entity)
 {
     using (var db = new ContosoDBContext())
     {
         var cor = db.Course.Where(c => c.Id == entity.Id).FirstOrDefault();
         if (cor != null)
         {
             db.Course.Remove(entity);
             db.SaveChanges();
         }
     }
 }
Exemple #3
0
 public void Delete(Department entity)
 {
     using (var db = new ContosoDBContext())
     {
         var dep = db.Departments.Where(d => d.Id == entity.Id).FirstOrDefault();
         if (dep != null)
         {
             db.Departments.Remove(dep);
             db.SaveChanges();
         }
     }
 }
 public void Delete(Instructor entity)
 {
     using (var db = new ContosoDBContext())
     {
         var inst = db.Instructors.Where(ins => ins.Id == entity.Id).FirstOrDefault();
         if (inst != null)
         {
             db.Instructors.Remove(inst);
             db.SaveChanges();
         }
     }
 }
Exemple #5
0
        public void Delete(Person entity)
        {
            using (var db = new ContosoDBContext())
            {
                var person = db.People.Where(d => d.Id == entity.Id).FirstOrDefault();

                if (person != null)
                {
                    db.People.Remove(person);
                    db.SaveChanges();
                }
            }
        }