public IQueryable <SpellViewModel> GetAll(int?filter = null) { var query = _spellRepository.Select().ProjectTo <SpellViewModel>(MapperConfig) .OrderBy(x => x.MagicSchoolId).ThenBy(x => x.Level).AsQueryable(); return(filter is null ? query : query.Where(x => x.MagicSchoolId == filter)); }