Here is the post which describes the way to create an Expression<Func<MyClass, bool>>
predicate dynamically. Here is a snippet:
var param = Expression.Parameter(typeof(string), "p");
var len = Expression.PropertyOrField(param, "SomeText");
var body = Expression.Equal(
len, Expression.Constant("Text"));
var lambda = Expression.Lambda<Func<string, bool>>(
body, param);
I wonder how do I apply a regexp to a string instead of Equality. Is there a possibility? A possible pseudo code would be like:
var param = Expression.Parameter(typeof(string), "p");
var len = Expression.PropertyOrField(param, "SomeText");
var body = Expression.Regexp(
len, @"\D+");
var lambda = Expression.Lambda<Func<string, bool>>(
body, param);