我有以下查询:
var filtered = this.context;
if(!string.IsNullOrEmpty(filter1) {
filtered = filtered.Where(i => i.name == filter1);
}
if(!string.IsNullOrEmpty(filter2) {
filtered = filtered.Where(i => i.street == filter2);
}
if(!string.IsNullOrEmpty(filter3) {
filtered = filtered.Where(i => i.nummer == filter3);
}
....
是否可以使用一个具有以下行为的.Where
语句来编写它?
filtered = filtered.Where(if(!string.IsNullOrEmpty(filter1) { i.name == filter1})