We have an object and we want to build a linq query based on that object on the fly. This linq statement is equivalent to what we want to build:
Expression&l
You're getting confused by the "inner lambda". There's only one lambda expression:
var param = Expression.Parameter(typeof(Sample), "x");
var key = itemToCompare.GetType().GetProperty("Child");
var rhs = Expression.MakeMemberAccess(Expression.Constant(itemToCompare), key);
var lhs = Expression.MakeMemberAccess(param, key);
var body = Expression.Equal(lhs, rhs);
var lambda = Expression.Lambda<Func<Sample, bool>>(body, param);