假设我们有一个Human
s 的集合:
public class Human
{
public string FirstName { get; set; }
public string SecondName { get; set; }
public string CompanyName { get; set; }
}
var people = new List<Human>(){...};
我们如何在先按时FirstName
再按时对人SecondName
进行排序时实现自动完成CompanyName
?
我试过:
people.Where(x => x.FirstName.StartsWith(term) || x.SecondName.StartsWith(term)
|| x.CompanyName.StartsWith(term))
.OrderBy(x => x.FirstName).ThenBy(x => x.SecondName).ThenBy(x => x.CompanyName)
但这不能正常工作。我想FirstName
首先只查看所有匹配的字段,然后只查看SecondName
字段等等。