我有兩個類對象的數據viewModel。C#從ViewModel獲取類對象列表
public class StudentViewModel
{
public PeopleEntity People { get; set; }
public PeopleUnitEntity PeopleUnit { get; set; }
}
在下面的代碼,我得到兩個PeopleEntity和PeopleUnitEntity
IList<StudentViewModel> _stv = _StudentServicesObject.GetStudentByPersonCode(PersonCode);
我想存儲只有人名單新PeopleEntity對象的值,我該怎麼辦在於:
我嘗試如下,但它不爲我工作
IList<PeopleEntity> _People = _StudentServicesObject.GetStudentByPersonCode(PersonCode).Select(pl => new PeopleEntity { People = pl });
錯誤
爲什麼不能.ToList() –