public async Task <TEntity> GetByIdAsync(int id) { using WorksJwtContext context = new WorksJwtContext(); return(await context.Set <TEntity>().FindAsync(id)); }
public async Task <TEntity> GetByFilterAsync(Expression <Func <TEntity, bool> > filter) { using WorksJwtContext context = new WorksJwtContext(); return(await context.Set <TEntity>().FirstOrDefaultAsync(filter)); }
public async Task <List <TEntity> > GetAllByFilterAsync(Expression <Func <TEntity, bool> > filter) { using WorksJwtContext context = new WorksJwtContext(); return(await context.Set <TEntity>().Where(filter).ToListAsync()); }
public async Task <List <TEntity> > GetAllAsync() { using WorksJwtContext context = new WorksJwtContext(); return(await context.Set <TEntity>().ToListAsync()); }
public async Task DeleteAsync(TEntity entity) { using WorksJwtContext context = new WorksJwtContext(); context.Set <TEntity>().Remove(entity); await context.SaveChangesAsync(); }
public async Task InsertAsync(TEntity entity) { using WorksJwtContext context = new WorksJwtContext(); context.Set <TEntity>().Add(entity); await context.SaveChangesAsync(); }