0

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));

            }
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
Goldentp
  • 187
  • 1
  • 7
  • 28

1 Answers1

2

try

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

due to you using the 'Or' join.

Dene B
  • 486
  • 4
  • 9