示例#1
0
        public IActionResult Eliminar(int id)
        {
            var productos = _context.Productos.FirstOrDefault(x => x.id == id);

            _context.Remove(productos);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
        public void DeleteAll()
        {
            var persons = _context.Persons.Where(p => true).ToList();

            foreach (var person in persons)
            {
                var entity = _context.Persons.Find(person.PersonId);
                _context.Remove(entity);
            }

            _context.SaveChanges();
        }
示例#3
0
        public async Task DeleteAllAsync()
        {
            var employees = await _context.Employees.Where(e => true).ToListAsync();

            List <Task <Employee> > tasks = new List <Task <Employee> >();

            foreach (var employee in employees)
            {
                tasks.Add(_context.Employees.FindAsync(employee.EmployeeId));
            }
            var entities = await Task.WhenAll(tasks);

            foreach (var entity in entities)
            {
                _context.Remove(entity);
            }

            await _context.SaveChangesAsync();
        }
示例#4
0
        public async Task DeleteAllAsync()
        {
            var customers = await _context.Customers.Where(e => true).ToListAsync();

            List <Task <Customer> > tasks = new List <Task <Customer> >();

            foreach (var customer in customers)
            {
                tasks.Add(_context.Customers.FindAsync(customer.CustomerId));
            }
            var entities = await Task.WhenAll(tasks);

            foreach (var entity in entities)
            {
                _context.Remove(entity);
            }

            await _context.SaveChangesAsync();
        }
示例#5
0
        public async Task DeleteAllAsync()
        {
            var Appointments = await _context.Appointments.Where(e => true).ToListAsync();

            List <Task <Appointment> > tasks = new List <Task <Appointment> >();

            foreach (var Appointment in Appointments)
            {
                tasks.Add(_context.Appointments.FindAsync(Appointment.AppointmentId));
            }
            var entities = await Task.WhenAll(tasks);

            foreach (var entity in entities)
            {
                _context.Remove(entity);
            }

            await _context.SaveChangesAsync();
        }
示例#6
0
 public EntityEntry <TEntity> Remove <TEntity>(TEntity entity) where TEntity : class, IBaseEntity
 {
     return(_context.Remove(entity));
 }
 public void Delete(Student student)
 {
     _context.Remove(student);
 }