Imagine I have a class like this
public class Person
{
public string Surname {get; set;}
public string GivenNames {get; set;}
public DateTime DateOfBirth {get; set;}
}
The user selects which properties they want to retrieve and stores these in a
List<String> RetrieveProperties
Now I want to use a linq select statement to select only those properties which the user has specified without knowing at design time what these are. Can I do something like this?
var result = qry.Where(x=>x.RetrieveProperties[i])
Getting an anonymous object like that would allow a DataGrid
to bind to the collection and neatly display only what the user has selected.
Can this be done?