I'm dynamically building linq queries for nHibernate.
Due to dependencies, I wanted to cast/retrieve the typed expression at a later time, but I have been unsuccessfull so far.
This is not working (the cast is supposed to happen elsewhere):
var funcType = typeof (Func<,>).MakeGenericType(entityType, typeof (bool));
var typedExpression = (Func<T, bool>)Expression.Lambda(funcType, itemPredicate, parameter); //Fails
This is working:
var typedExpression = Expression.Lambda<Func<T, bool>>(itemPredicate, parameter);
Is it possible to get the 'encapsulated' typed expression from a LambdaExpression?