示例#1
0
 public void Update(Phone model)
 {
     using (PersonsPhonesContext context = new PersonsPhonesContext())
     {
         Phone original = context.Phones.FirstOrDefault(x => x.Id == model.Id);
         context.Entry(original).CurrentValues.SetValues(model);
         context.SaveChanges();
     }
 }
示例#2
0
 public void Update(Person model)
 {
     using (PersonsPhonesContext context = new PersonsPhonesContext())
     {
         foreach (var phone in model.Phones)
         {
             if (phone.Id == 0)
             {
                 phone.Person   = null;
                 phone.PersonId = model.Id;
                 phoneDAO.Create(phone);
             }
         }
         Person original = context.Persons.FirstOrDefault(x => x.Id == model.Id);
         context.Entry(original).CurrentValues.SetValues(model);
         context.SaveChanges();
     }
 }