tags:

views:

187

answers:

0

Hi,

I have a function that I want to call in a classmethod to dynamically add where condition but for some reason getting syntax error. Please help me with the code

private DataTable CustomSearch<TKey>(this DataTable dt, Func<Records, bool> selector)
   {
       DataTable results = (dt.AsEnumerable().Where(selector).CopyToDataTable());
       return results;
   }

How can I call it

if (ProjDDL1.Text != "") results = results.CustomSearch<Records>(results, s => s.Business == ProjDDL1.Text);

Getting syntax error on CustomSearch. What is missing or not correct?