I am looking in a way to build an internal search engine that gonna search transactions depending on criterias.
The problem i have is more criteria mean more checks.. so if there is 6 criteria.. i almost have to do 6 x 6 = 36 ELSE in an IF statement. That huge.. i am pretty sure there some other way to do it.
Explanation : If i have an object which have A,B,C,D,E,F i have to check if
A,B,C,D,E NOT F
A,B,C,D, NOT E, F
A,B,C, NOT D, E, F
etc..
So how i could handle this ? (I am using C# with WPF)
EDIT: Here more details.
- This is code not SQL.
- The number of criteria that must be evaluated depend on the user.
Thanks.
The way to do this kind of thing is to build some kind of expression tree. This might just be List of criteria objects. Each object has a “check” method to say whether or not the element passes the test. You can build this list at run time, then use it to check every candidate.
Or look at LINQ. It’s perfectly suited.