Ejemplo n.º 1
0
        public void Update(T entity)
        {
            using var context = new ShopContext();
            var updatedEntity = context.Entry(entity);

            updatedEntity.State = EntityState.Modified;
            context.SaveChanges();
        }
Ejemplo n.º 2
0
 public void Delete(T entity)
 {
     using (var context = new ShopContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void Create(T entity)
 {
     using (var context = new ShopContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }