我在Silverlight中有一个下拉框,它的值集合是由我的LINQ-to-SQL对象的属性(例如:名称、地址、年龄等)构建而成。我想根据下拉框选定的值来过滤结果。
例如:我想要所有姓“史密斯”的人。我会从下拉列表中选择“姓氏”,然后在文本框中输入smith。通常情况下,我会编写类似于以下的LINQ查询语句...
var query = from p in collection where p.LastName == textbox.Text select p;
是否可以动态地决定属性,也许使用反射?像这样:
var query = from p in collection where p.(DropDownValue) == textbox.Text select p;
例如:我想要所有姓“史密斯”的人。我会从下拉列表中选择“姓氏”,然后在文本框中输入smith。通常情况下,我会编写类似于以下的LINQ查询语句...
var query = from p in collection where p.LastName == textbox.Text select p;
是否可以动态地决定属性,也许使用反射?像这样:
var query = from p in collection where p.(DropDownValue) == textbox.Text select p;