Skip to content

Instantly share code, notes, and snippets.

@kmorcinek
Created September 16, 2015 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmorcinek/7728c3153dd1b62c393f to your computer and use it in GitHub Desktop.
Save kmorcinek/7728c3153dd1b62c393f to your computer and use it in GitHub Desktop.
public static class IQueryableExtensions
{
public static IOrderedQueryable<TSource> OrderBy<TSource, TKey>(
this IQueryable<TSource> source,
Expression<Func<TSource, TKey>> keySelector,
bool isAscending)
{
if (isAscending)
{
return source.OrderBy(keySelector);
}
else
{
return source.OrderByDescending(keySelector);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment