Ejemplo n.º 1
0
        public async Task AddAsync(TEntity entity)
        {
            using var context = new UdemyBlogContext();
            await context.Set <TEntity>().AddAsync(entity);

            await context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
 public async Task <TEntity> GetAsync(Expression <Func <TEntity, bool> > filter)
 {
     using var context = new UdemyBlogContext();
     return(await context.Set <TEntity>().FirstOrDefaultAsync(filter));
 }
Ejemplo n.º 3
0
 public async Task <List <TEntity> > GetAllAsync <TKey>(Expression <Func <TEntity, TKey> > keySelector)
 {
     using var context = new UdemyBlogContext();
     return(await context.Set <TEntity>().OrderByDescending(keySelector).ToListAsync());
 }
Ejemplo n.º 4
0
 public async Task <List <TEntity> > GetAllAsync(Expression <Func <TEntity, bool> > filter)
 {
     using var context = new UdemyBlogContext();
     return(await context.Set <TEntity>().Where(filter).ToListAsync());
 }
Ejemplo n.º 5
0
        public async Task <List <TEntity> > GetAllAsync()
        {
            using var context = new UdemyBlogContext();

            return(await context.Set <TEntity>().ToListAsync());
        }
Ejemplo n.º 6
0
 public async Task <TEntity> FindByIdAsync(int id)
 {
     using var context = new UdemyBlogContext();
     return(await context.Set <TEntity>().FindAsync(id));
 }