Last active
May 17, 2020 23:30
-
-
Save zHaytam/0f707e5c82a733955231877ad0c7d17e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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