I am using EfRepository<TEntity> to access data and I have a DbSet<TEntity>.
I'm trying to access data asynchronously and I need it is as Queryable and I'm currently using this:
public virtual async Task<IQueryable<TEntity>> AllAsync()
{
var list = await this.DbSet.ToListAsync();
return list.AsQueryable();
}
Is it actually faster than using the DbSet synchronously?
Much, much, much slower actually. That will load all the entities into memory before returning an in-memory IQueryable.
Your additional, second-level repository should return the DbSet directly as an
IQueryable<T>. It's up to the calling code to specify the query and execute it either sync or async.Lots of people have written "generic repository" wrappers for EF. They all add complexity, and most of them do more harm than good.