Question

I have been messing with Predicate Builder for two days now and although every website says it is super easy to implement for some reason(most likely my fault) I cannot get it to work. I decided to use Predicate builder because I know which columns I would like to search and and it is all within the same table. All I am trying to do is search multiple columns for a keyword that could exist in any of the 3 columns. I have read that Predicate Builder could accomplish this easily but the tutorial's did not account for me apparently. Below is what I have so far, if anyone can point me in the right direction I would appreciate it. Right now it is not doing anything when I search, it just returns all the records. Thanks for your help!

if (!String.IsNullOrEmpty(searchString))
            {


                var predicate = PredicateBuilder.True<iamp_mapping>();



                predicate = predicate.Or(p => p.PA.Contains(searchString));
                predicate = predicate.Or(p => p.MAJOR_PROGRAM.Contains(searchString));
                predicate = predicate.Or(p => p.INVESTMENT_AREA.Contains(searchString));

            }
Était-ce utile?

La solution

try

var predicate = PredicateBuilder.False<iamp_mapping>();

due to you using the 'Or' join.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top