Let me explain
I do not have search strings and my list contains different fields.
Now I will not specify the search lines at a time, then my predicate will search for each element of the list using a search.
After the match, I get one predicate.
For the next iteration of the search, I will get another predicate, it may be the same element from the list, because I'm not looking in the same list box.
So, after receiving all the predicate objects, I combine them and assign them to one.
But I get an exception.
string[] separator = new string[] { "+" };
string[] searchItems = s.Split(separator, StringSplitOptions.None);
foreach (string str in searchItems)
{
_defaultPredicate = _defaultPredicate.And(e =>
e.Name.ToLower().Contains(str) ||
e.Lname.ToLower().Contains(str) ||
e.Job.ToLower().Contains(str) );
Predicates.Add(_defaultPredicate);
}
foreach (Expression<Func<Alert, bool>> Predicate in Predicates)
{
_currentPredicate = _currentPredicate.Or(Predicate);
_currentPredicate.Compile();
}
What to do? How to remove duplicate values?
source
share