I need to create functionality that will allow users to filter objects using literals (i.e. age gt 20 and name eq 'john' ). Is there a provided function for this in C # / Asp.Net MVC or do I need to parse this request myself?
I found that OData implies the presence of such functionality ( OData Filter Expressions MSDN ). However, I am not familiar with this, so I do not know how to implement this behavior in my project.
I need something like this:
var list = new List<Person> { new Person { Name = "John", Age = 30 }, new Person { Name = "Hanna", Age = 25 }, new Person { Name = "John", Age = 15 } }; string query = "age gt 20 and name eq /'John/'"; IEnumerable<Person> result = list.FilterByExpression(query);
Any advice would be appreciated.
source share