Can you use text strings to filter a List of objects?

  • Thread starter Thread starter Kenmtb
  • Start date Start date
K

Kenmtb

Guest
I am trying to filter a list of data objects using a user defined string as the where clause.
So far linq lets me specify only part of the clause (str). The rest needs to be hard coded and handled with if statements.

string str = "male";
IEnumerable<Models.EmployeeDepartment> ellist = el.Where( g => g.Gender == str);

Is there a way to allow users to build a string like: "Gender =='male'" ?

I looked at datagridview filtering but it does not look doable unless the datasource is a table.

Continue reading...
 
Back
Top