public MoviesContextBuilder AddEntities <TEntity>(params TEntity[] entities) where TEntity : class { foreach (var entity in entities) { _context.Set <TEntity>().Add(entity); } _context.SaveChanges(); return(this); }
public async Task <TEntity> GetBy(Expression <Func <TEntity, bool> > predicate, params Expression <Func <TEntity, object> >[] includeProperties) { IQueryable <TEntity> query = _dbContext.Set <TEntity>(); foreach (var includeProperty in includeProperties) { query = query.Include(includeProperty); } return(await query.Where(predicate).FirstOrDefaultAsync()); }
public async Task <T> AddAsync(T entity) { await _moviesContext.Set <T>().AddAsync(entity); return(await Task.FromResult(entity)); }
public bool Exists(int id) { return(_context.Set <T>( ) .Any(x => x.Id == id)); }
public virtual async Task <T> GetByIdAsync(int id) { return(await _dbContext.Set <T>().FindAsync(id)); }
public BaseRepository(MoviesContext context) { Context = context; DbSet = context.Set <T>(); }