如何将linq查询转换为ToList

时间:2018-10-21 03:34:12

标签: linq

如何将查询转换为列表?

我尝试了几种不同的方法来列出此查询,但是我无法成功。

var parent =
from s in Students
where s.Id==5027
select new { 
    ID_PK = (s.CaseOwnerIdAspnet_Users.User_ID_FKDYN_User_Profile.Organization_ID_FKDYN_Organization.Parent_ID_FK == null ?
    (int) s.CaseOwnerIdAspnet_Users.User_ID_FKDYN_User_Profile.Organization_ID_FKDYN_Organization.ID_PK
    :
    (int) s.CaseOwnerIdAspnet_Users.User_ID_FKDYN_User_Profile.Organization_ID_FKDYN_Organization.Parent_ID_FK)
    };

1 个答案:

答案 0 :(得分:0)

尝试一下...

var list =parent.ToList();