public void Delete(T entity) { using (LibertadContext context = new LibertadContext()) { context.Entry(entity).State = EntityState.Deleted; context.SaveChanges(); } }
public void Create(T entity) { using (LibertadContext context = new LibertadContext()) { context.Set <T>().Add(entity); context.SaveChanges(); } }
public void Delete(Expression <Func <T, bool> > predicate) { using (LibertadContext context = new LibertadContext()) { var entities = context.Set <T>().Where(predicate).ToList(); entities.ForEach(x => context.Entry(x).State = EntityState.Deleted); context.SaveChanges(); } }