Example #1
0
 public void Delete(Product entity)
 {
     using (MyDataBaseContext context = new MyDataBaseContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Example #2
0
 public void Update(Product entity)
 {
     using (MyDataBaseContext context = new MyDataBaseContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #3
0
 public void Add(Product entity)
 {
     using (MyDataBaseContext context = new MyDataBaseContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }