Skip to content

Instantly share code, notes, and snippets.

@zHaytam
Last active May 17, 2020 23:30
Show Gist options
  • Save zHaytam/0f707e5c82a733955231877ad0c7d17e to your computer and use it in GitHub Desktop.
Save zHaytam/0f707e5c82a733955231877ad0c7d17e to your computer and use it in GitHub Desktop.
public IQueryable<Product> ApplyFilter(IQueryable<Product> query, string property, object value)
{
switch (property)
{
case "Name":
return query.Where(p => p.Name.Contains(value.ToString()));
case "Quantity":
return query.Where(p => p.Quantity >= value);
case "Price":
return query.Where(p => p.Price >= value);
default:
return query;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment