public void Writer_ApplySortOrder_InOrder() { var fieldSorter = new QueryableFieldSorter <Artist>(new FieldDictionary <Artist> { { "id", a => a.ID } }, new[] { new SortInstruction("id", SortDirection.Ascending) }); var unordered = new List <Artist> { new Artist(12, "Periphery"), new Artist(3, "Noisia"), new Artist(78, "Mefjus"), new Artist(43, "Drewsif Stalin"), new Artist(24, "Tesseract") }; var ordered = fieldSorter.ApplySortOrder(unordered.AsQueryable()).ToList(); Assert.True(ordered[0].ID < ordered[1].ID); Assert.True(ordered[1].ID < ordered[2].ID); Assert.True(ordered[2].ID < ordered[3].ID); Assert.True(ordered[3].ID < ordered[4].ID); }
public IQueryable <TItem> BuildQueryable() { IQueryable <TItem> items = _context.Repository.GetAllItems(); items = _context.AuthorizationChecker.ApplyFilter(items); if (_query == null) { return(items); } var filter = new QueryableFieldFilter <TItem>(_context.Fields, _query.FilterInstructions); items = filter.ApplyFilter(items); var sorter = new QueryableFieldSorter <TItem>(_context.Fields, _query.SortInstructions); items = sorter.ApplySortOrder(items); items = _pager.ApplyPagination(items); return(items); }