I have a this line of code:
var predicate = Expression.Lambda<Func<TEntityType, bool>>(body, param);
where TEntityType is a generic parm.
However, I don't have generic parm available. I do have:
Type _EntityType;
What is the non-generic syntax for Expression.Lambda is this case?
Thanks
There's an overload for Expression.Lambda
that takes the type of the expression body, so you just need to create the type dynamically before calling that overload.
type lambdaType = typeof(Func<,>).MakeGenericType(_EntityType, typeof(bool));
var predicate = Expression.Lambda(lambdaType, body, param);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With