【发布时间】:2017-05-21 17:21:35
【问题描述】:
我在列表中使用了多个 where 过滤器项目。如果某些过滤器字段为空,如何正确跳过某些 where 块?
IEnumerable<MyNewClass> filterResult = itemList.Where(s => s.name == nameFilterTextBox.Text)
.Where(s => s.description == descriptionFilterTextBox.Text)
.Where(s => s.color == (MyNewClass.Colors)comboBox1.SelectedIndex).ToList();
【问题讨论】:
-
你可以使用规范模式