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?
I use something similiar, where I add filters to a query.
Usage, to apply filter against a property whose name matches Key, and using supplied value, Value.
And yes, this method works with contains:
By having those 2 examples, you can more easily understand how we can call various different methods by name.