这是目标:获取一个通用的人员列表,并在我的模型中按男性、女性和儿童进行排序......为了这个网站和我的隐私,我还重命名了一些东西。请关注下面的 lambda 表达式!谢谢!
我收到此错误:
无法转换
System.Collections.Generic.IEnumerable<bool>
为System.Collections.Generic.IEnumerable<Project1.DataClasses.DataObjects.People>
人物模型:
public List< People> Men { get; set; }
public List< People> Women { get; set; }
public List< People> Kids { get; set; }
public List< People> Babies { get; set; }
控制器:
public ActionResult GetPeople(PeopleModels Peoples)
{
List<People> listPeoples = new List<People>();
listPeoples = DataClass.GetAllPeoples();
// this is the code I cannot get to work.
var men = listPeoples .Select(m => m.Sex == "M");
Peoples.Men = men.ToList<People>();
// Women, Children too..
return View("Employees", Peoples);
}