Expression Tree Binary Expression for an 'In' operation

Posted by Adam Driscoll on Stack Overflow See other posts from Stack Overflow or by Adam Driscoll
Published on 2010-03-23T16:22:31Z Indexed on 2010/03/23 16:23 UTC
Read the original article Hit count: 560

Filed under:
|
|
|

I'm trying to build an expression tree (still) but getting further! I need to create a BinaryExpression to perform an 'In' comparison between a Member and a collection of items. Hence, the expression should return true if the member is contained within the items.

This obviously does not exist:

Expression.MakeBinary(ExpressionType.In, memberExpression, constantExpression);

constantExpression is a ConstantExpression of type IEnumerable while memberExpression is a MemberExpression of type T.

How would I create such an expression?

© Stack Overflow or respective owner

Related posts about expression-trees

Related posts about .NET