How to convert a ExpressionTree of form
Expression<Func<POCO1, bool>> exp = p => p.Age > 50;
to
Expression<Func<POCO2, bool>> exp2 = p => p.Age > 50;
where POCO1 and POCO2 are C# objects and both have Int32 Age property
How to convert a ExpressionTree of form
Expression<Func<POCO1, bool>> exp = p => p.Age > 50;
to
Expression<Func<POCO2, bool>> exp2 = p => p.Age > 50;
where POCO1 and POCO2 are C# objects and both have Int32 Age property
well, you can make custom expression visitor that will replace parameter references and patch member access expressions
Rough Steps:
The type you get here is a property without setter as I guessed.
So you must build a new expression
Here is the way
manually build linq expression for x => x.Child == itemToCompare.Child
Ideally - you don't. Make an interface that describes the Age property, and build the expression to refer to that. If you can't modify the POCO types, use a language like Go, where interfaces are implicit :-).