Skip to content

Instantly share code, notes, and snippets.

@zHaytam
Last active May 17, 2020 23:37
Show Gist options
  • Save zHaytam/ff714ab68515b91b23a6466c5c3ddb22 to your computer and use it in GitHub Desktop.
Save zHaytam/ff714ab68515b91b23a6466c5c3ddb22 to your computer and use it in GitHub Desktop.
var predicate = DynamicExpressions.GetPredicate<Product>(propertySentByUser, operatorSentByUser, valueSentByUser);
// ^ can also be cached or compiled and used anywhere
var products = _dbContext.Products.AsQueryable().Where(predicate).ToList();
// ^ or FirstByDefault, Any, etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment