none
通过Linq增加树节点报错 RRS feed

  • 问题

  • 请看代码

    Dim tasklistdata As New lqDataContext
        Dim UserID As Integer
        UserID = (From vwUser In tasklistdata.Operators _
                 Where vwUser.UserName Is Login.txtUsername.Text _
                 Select vwUser.OperatorID).Single
     
        Dim lqHospitalList = From vwHospitalList In tasklistdata.SPM_Accounts _
                              Where vwHospitalList.OperatorID = UserID _
                              Order By vwHospitalList.CustomerName, vwHospitalList.Class _
                              Select vwHospitalList.CustomerName, vwHospitalList.Class, vwHospitalList.ClassCount, vwHospitalList.Charges
        tvHospitalSelect.Nodes.Add(lqHospitalList(0).CustomerName)
     
    错误信息:”operator note supported”
    2016年2月4日 14:03

答案

  • 你好,

    Linq 查询不是List, 要遍历所有你可以使用foreach这样的项目:

    For Each hospital In lqHospitalList
        tvHospitalSelect.Nodes.Add(hospital.CustomerName)
    Next

    可以ToList

    lqHospitalList.ToList

    可以ToArrary

    lqHospitalList.ToArray

    Best regards,

    Cole Wu

    2016年2月6日 6:53
    版主