1

这是获取部门列表并在顶部添加自定义“全选”的代码


IList<Division> divisionList = divisionService.GetAllDivisions();
divisionList.Insert(0, new Division() { Code = "ALL", CodeName = "Select all" });

然后根据代码过滤它,我在 newList 中得到 1 个项目


var newList = divisionList.Where(x => x.Code == "01" ).ToList();

问题是如何选择多个项目并将其存储在 newList 中,包括“全选”使用此语句获取一个空列表,


var newList = divisionList.Where(x => x.Code == "01" && x.Code == "02" ).ToList(); 

4

1 回答 1

0

我认为你想要一个合乎逻辑的或不合乎逻辑的并且......像这样:

var newList = divisionList.Where(x => x.Code == "01" || 
                                      x.Code == "02" || 
                                      x.Code == "All" ).ToList(); 
于 2013-01-17T21:36:46.490 回答