Skip to content

Instantly share code, notes, and snippets.

@zHaytam
Created May 17, 2020 23:15
Show Gist options
  • Save zHaytam/c97dccf923440a5820ba7032b2a5783b to your computer and use it in GitHub Desktop.
Save zHaytam/c97dccf923440a5820ba7032b2a5783b to your computer and use it in GitHub Desktop.
public IQueryable<Product> ApplyOrderBy(IQueryable<Product> query, string property)
{
switch (property)
{
case "Name":
return query.OrderBy(p => p.Name);
case "Quantity":
return query.OrderBy(p => p.Quantity);
case "Price":
return query.OrderBy(p => p.Price);
default:
return query;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment