There is a DisplayNameFor(x=>x.Title)
helper in ASP.Net MVC.
I want to implement something similar in behavior.
I want to have a method that accepts an expression based on User
class (u=>u.Birthdate
or u=>u.Name), a operand (Greater, Less, Equal) and a value like DateTime.Now
and returns an expression u=>u.Birthdate > DateTime.Now
I understand that I'll have to build resulting expression manually from pieces. What i can't wrap my head around is passing in and handling of property expression.
Edit:
I want to call a method like
GetFilterPredicate(u=>u.Birthdate,FilterOps.GreaterThan,DateTime.Parse("01.01.2013")
or
GetFilterPredicate(u=>u.SomeIntProperty,FilterOps.Equals,2)
Update: I've created a repo with a solution to this question as well as a collection property filtering https://github.com/Alexander-Taran/Lambda-Magic-Filters