I populate the dropdown using the following:
var columnNames = db.Mapping.MappingSource.GetModel(typeof(StaffDirectoryDataContext)) .GetMetaType(typeof(Person)).DataMembers;
Then I will convert this to List<String> to populate the drop down list.
Then I want to get a result set based on user selection. For example, if they select “Name” from the drop-down list and type “Bob” in the text box, I want to run a LINQ query, where name is name = bob.
I’m probably fat, but I can’t find a way! The pseudo code will be ...
var q = from x in dc.Persons where x.[selected column name] == [textbox value] select x;
Can anyone help? Essentially, I have the column name as a String value, and I cannot figure out how to tell the LINQ query that this filter will be filtered!
I could do it in ADO.NET with my eyes closed, but decided to use LINQ all the way!
Thanks in advance.
source share