错误无法将System.Collections.Generic.List类型的对象强制转换为System.Linq.IQueryable类型

时间:2017-03-02 20:45:57

标签: vba odata

我的代码是:

'GET:odata / Event_Game_Schedule

    <EnableQuery>
    Function GetEvent_Game_Schedule() As IQueryable(Of Event_Game_Schedule)
        Dim schedule As New List(Of Event_Game_Schedule)
        schedule = db.Event_Game_Schedule.ToList()
        For Each x As Event_Game_Schedule In schedule
            x.hometeamid = (From t In db.Teams Where t.id = x.hometeamid Select t.name).FirstOrDefault
            x.visitorteamid = (From t In db.Teams Where t.id = x.visitorteamid Select t.name).FirstOrDefault
        Next

        Return schedule.AsQueryable.ToList()
    End Function

我做错了什么..这是一个控制器,我想要返回团队的名称,而不是API中的teamid。

感谢

1 个答案:

答案 0 :(得分:0)

我找到了我只需要添加ASQueryable部分的答案..而不是.ToList()

这是vb.net项目的visual Basic