Example #1
0
 public void Update(T entity)
 {
     using (var db = new YGFLDBEntities())
     {
         db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #2
0
 public void Add(T entity)
 {
     using (var db = new YGFLDBEntities())
     {
         db.Set <T>().Add(entity);
         db.SaveChanges();
     }
 }
Example #3
0
 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();
     }
 }