public IQueryable <TSource> Sort <TSource>( IQueryable <TSource> source) { if (!SortOperations.Any()) { return(source); } IOrderedQueryable <TSource> sortedSource; if (!OrderingMethodFinder.OrderMethodExists(source.Expression)) { sortedSource = source.AddInitialSortOperation( SortOperations.Dequeue()); } else { sortedSource = (IOrderedQueryable <TSource>)source; } while (SortOperations.Any()) { sortedSource = sortedSource.AddSortOperation( SortOperations.Dequeue()); } return(sortedSource); }
public IQueryable <TSource> Sort <TSource>( IQueryable <TSource> source) { if (!SortOperations.Any()) { return(source); } IOrderedQueryable <TSource> sortedSource = source.AddInitialSortOperation( SortOperations.Dequeue()); while (SortOperations.Any()) { sortedSource = sortedSource.AddSortOperation( SortOperations.Dequeue()); } return(sortedSource); }