public int Delete(User entity) { _dbContext.Set <User>().Remove(entity); int a = _dbContext.SaveChanges(); return(a); }
public async Task Delete(int id) { var entity = await GetById(id); if (entity == null) { throw new Exception("The entity is null"); } universityContext.Set <TEntity>().Remove(entity); await universityContext.SaveChangesAsync(); }
// GET: Students/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var student = await _context.Student.FindAsync(id); if (student == null) { return(NotFound()); } ViewData["AddressId"] = new SelectList(_context.Set <Address>(), "Id", "Id", student.AddressId); return(View(student)); }
public async Task Delete(int id) { // Obtener la entidad por un id var entity = await GetById(id); // Se valida si existe if (entity == null) { throw new Exception("La entidad es nula."); } // Elimina la entidad no el task con el código Linkq universityContext.Set <TEntity>().Remove(entity); await universityContext.SaveChangesAsync(); }
public StudentService(UniversityContext ctx) : base(ctx) { _ctx = ctx; if (_ctx == null) { throw new ArgumentNullException(nameof(UniversityContext)); } dbSet = _ctx.Set <Student>(); }
public GenericService(UniversityContext ctx) { _ctx = ctx; if (_ctx == null) { throw new ArgumentNullException(nameof(UniversityContext)); } dbSet = _ctx.Set <T>(); }
public Repository(UniversityContext context) { _context = context; _dbSet = _context.Set <T>(); }
public GenericRepository(UniversityContext context) { this.context = context; this.dbSet = context.Set <TEntity>(); }
public Repository(UniversityContext context) { this.context = context; entities = context.Set <T>(); }
public GenericRepository(UniversityContext ctx) { _ctx = ctx; _dbSet = ctx.Set <T>(); }
public GenericRepository(UniversityContext _context) { this.context = _context; this.table = context.Set <T>(); }
// GET: Courses/Create public IActionResult Create() { ViewData["FirstTeacherId"] = new SelectList(_context.Set <Teacher>(), "Id", "FullName"); ViewData["SecondTeacherId"] = new SelectList(_context.Set <Teacher>(), "Id", "FullName"); return(View()); }
public StudentRepository(UniversityContext universityContext) { UniversityContext = universityContext; DbSet = UniversityContext.Set <Student>(); }
public virtual async Task AddAsync(TEntity entity) { await context.Set <TEntity>().AddAsync(entity); }
public async Task <int> Count() { return(await universityContext.Set <TEntity>().CountAsync()); }