views:

31

answers:

1

How do I check the type of a Parameter in an Expression Tree (and get the Expression Tree equivalent of a bool if it the right type)? If it were normal code, I would do this:

if(myObj is int)

I see there is a Expression.Convert method but this converts the object instead of just checking its type.

EDIT: I found the answer, you use a Expression.TypeIs

+2  A: 

You can use the Expression.TypeIs method :

var isExpression = Expression.TypeIs(parameterExpression, typeof(SomeType));
Thomas Levesque
I found the answer already, but I'll give you rep for being nice and answering :)
Callum Rogers