I need to create a Expression to make it like:
Expression<Func<MyDataSet, bool>> searchfilter = null;
string[] strsearchvalues = Searchvalues.Split(',');
searchfilter = p => p.searchcolumn.contains(strsearchvalues[0]) && p.searchcolumn.contains(strsearchvalues[1]) && ....
I tried this one but it doesn’t work:
Expression<Func<MyDataSet, bool>> columnfilter = null;
foreach(var s in strsearchvalues)
{
columnfilter = p => p.searchcolumn.contains(s);
searchfilter = columnfilter.And(columnfilter);
}
If the search value is “bob Smith”, I want to the result returns the column contains both bob and smith, like “boby smither’ or ‘smither boby’. With the above code, it returns ‘boby something’ or ‘smith something’.
How can I create an Expression with a loop to get it done?
Thanks!
Try do it like this:
Hope this could be helpful to you…