public async Task <IEnumerable <T> > GetAll(Expression <Func <T, bool> > filter = null, Func <IQueryable <T>, IOrderedQueryable <T> > orderBy = null, string includeProperties = "") { var query = DBSet.AsQueryable(); if (filter != null) { query = query.Where(filter); } foreach (var includeProperty in includeProperties.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { query = query.Include(includeProperty); } return(orderBy != null ? await orderBy(query).ToListAsync() : await query.ToListAsync()); }