Пример #1
0
 public void Update(Contact contact)
 {
     using (var db = new TradeEntities())
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #2
0
 public void Create(Contact contact)
 {
     using (var db = new TradeEntities())
     {
         db.Contact.Add(contact);
         db.Entry(contact).State = EntityState.Added;
         db.SaveChanges();
     }
 }
Пример #3
0
 public void Delete(int id)
 {
     using (var db = new TradeEntities())
     {
         var item = db.Contact.Find(id);
         if (item == null)
         {
             return;
         }
         db.Entry(item).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }