public void Update(T entity) { using (var db = new YGFLDBEntities()) { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void Add(T entity) { using (var db = new YGFLDBEntities()) { db.Set <T>().Add(entity); db.SaveChanges(); } }
public void DeleteById(int id) { using (var db = new YGFLDBEntities()) { T entity = db.Set <T>().Find(id); if (entity != null) { db.Set <T>().Remove(entity); } db.SaveChanges(); } }