public async Task InsertAsync(T entity)
        {
            using var context = new BlogProjectContext();
            await context.Set <T>().AddAsync(entity);

            await context.SaveChangesAsync();
        }
 public async Task <T> GetByIdAsync(int id)
 {
     using var context = new BlogProjectContext();
     return(await context.Set <T>().FindAsync(id));
 }
 public async Task DeleteAsync(T entity)
 {
     using var context = new BlogProjectContext();
     context.Set <T>().Remove(entity);
     await context.SaveChangesAsync();
 }
 public async Task <T> GetAsync(Expression <Func <T, bool> > filter)
 {
     using var context = new BlogProjectContext();
     return(await context.Set <T>().FirstOrDefaultAsync(filter));
 }
 public async Task <List <T> > GetAllAsync <TKey>(Expression <Func <T, TKey> > keySelector)
 {
     using var context = new BlogProjectContext();
     return(await context.Set <T>().OrderByDescending(keySelector).ToListAsync());
 }
 public async Task <List <T> > GetAllAsync(Expression <Func <T, bool> > filter)
 {
     using var context = new BlogProjectContext();
     return(await context.Set <T>().Where(filter).ToListAsync());
 }
 public async Task <List <T> > GetAllAsync()
 {
     using var context = new BlogProjectContext();
     return(await context.Set <T>().ToListAsync());
 }
 public DbSet <T> Set()
 {
     return(_db.Set <T>());
 }