Skip to content

Instantly share code, notes, and snippets.

@zHaytam
Last active May 17, 2020 23:19
Show Gist options
  • Save zHaytam/20b52ba9690786d2a9772aa74144c7ea to your computer and use it in GitHub Desktop.
Save zHaytam/20b52ba9690786d2a9772aa74144c7ea to your computer and use it in GitHub Desktop.
var propertyGetter = DynamicExpressions.GetPropertyGetter<Product>(propertySentByUser);
// ^ can be cached or even compiled to a Func<Product, object>
var query = _dbContext.Products.AsQueryable().OrderBy(propertyGetter);
// Or OrderByDesceding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment