Home

Is there a way to dynamically assign the table type to the PredicateBuilder

Generically, the example would look like this:

var predicate = PredicateBuilder.False<T>();
bool normalize = true;
string[] criteriaStr = { arg1, arg2,arg3 };
string[] cols = {col1, col2, col3}; ** // Not sure about this at all...
for (i==0; i<criteriaStr.Count; i++)
{
var temp = normalize?criteriaStr [i].ToLower().Trim() : criteriaStr [i];
predicate = predicate.Or< **T
>(p=> (normalize?p.cols[i].ToLower().Trim() : p.cols[i]) == temp);
}
T.Where (predicate).Dump();

Where the set of T, criteria, and cols can be dynamic. May be beyond the PredicateBuilder purpose?
Thank you.

Allen

Comments

Sign In or Register to comment.