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(); } } }
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(); } } }
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(); } } }