Created
          September 16, 2012 17:16 
        
      - 
      
- 
        Save jonsagara/3733293 to your computer and use it in GitHub Desktop. 
    IQueryable<T> Extensions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static class LinqExtensions | |
| { | |
| public static IOrderedQueryable<TSource> OrderBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, bool isAscending) | |
| { | |
| return isAscending | |
| ? source.OrderBy(keySelector) | |
| : source.OrderByDescending(keySelector); | |
| } | |
| public static IOrderedQueryable<TSource> ThenBy<TSource, TKey>(this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, bool isAscending) | |
| { | |
| return isAscending | |
| ? source.ThenBy(keySelector) | |
| : source.ThenByDescending(keySelector); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment