public TEntity First(Func <TEntity, bool> func) { using (dbContext = dbContext.GetContext()) { return(dbContext.Set <TEntity>().FirstOrDefault(func)); } }
public async Task <TEntity> FirstAsync(Expression <Func <TEntity, bool> > expression) { using (dbContext = dbContext.GetContext()) { return(await dbContext.Set <TEntity>().FirstOrDefaultAsync(expression)); } }
public async Task AddAsync(TEntity entity) { using (dbContext = dbContext.GetContext()) { dbContext.Set <TEntity>().Add(entity); await dbContext.SaveChangesAsync(); } }
public GenericRepository(Contexts.DbContext dbContext) { this.dbContext = dbContext; }