I know I can write the following to generate lambda expression:
Expression<Func<string, bool>> lambda = s => s.Length == 5;
But is there any way to automatically generate expression for property? In other words is there strongly-typed analogue of this:
var property = Expression.Property("Name")
This will give you a lambda which returns the
Lengthproperty:If you don’t want the full lambda, but only the
MemberExpressionwhich accesses the property, you can do that: