Skip to content

Instantly share code, notes, and snippets.

View StillLearnin's full-sized avatar

Melvin Ray Herr StillLearnin

  • Pennsylvania, USA
View GitHub Profile
@StillLearnin
StillLearnin / gist:051f15aeceb84d86a0ae977564e1c19a
Created April 19, 2018 23:49 — forked from neoGeneva/gist:1878868
An OrderBy extension method for IQueryable that takes string
public static IQueryable<T> OrderBy<T>(this IQueryable<T> source, string sortExpression)
{
if (source == null)
throw new ArgumentNullException("source", "source is null.");
if (string.IsNullOrEmpty(sortExpression))
throw new ArgumentException("sortExpression is null or empty.", "sortExpression");
var parts = sortExpression.Split(' ');