LINQ Expression<Func<T, bool>> equavalent of .Contains()

Posted by BK on Stack Overflow See other posts from Stack Overflow or by BK
Published on 2010-03-17T09:09:50Z Indexed on 2010/03/17 9:31 UTC
Read the original article Hit count: 318

Filed under:
|

Has anybody got an idea of how to create a .Contains(string) function using Linq Expressions, or even create a predicate to accomplish this

public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expr1,
      Expression<Func<T, bool>> expr2)
{
      var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast<Expression>());
      return Expression.Lambda<Func<T, bool>>
                  (Expression.OrElse(expr1.Body, invokedExpr), expr1.Parameters);
}

Something simular to this would be ideal?

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about linq-expressions