public void Delete(T entity) { using (LibertadContext context = new LibertadContext()) { context.Entry(entity).State = EntityState.Deleted; 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(); } }