Schedule
таблица:
ScheduleId(PK), AirplaneId(FK), OriginId(FK), Duration-String
Airplane
таблица:
AirplaneId(PK), PlaneCode-String
Origin
таблица:
OriginId(PK), OriginName-String
Я хотел что-то отобразитькак:
ScheduleId | PlaneCode | OriginName | Duration
Schedule.vb
Public Class Schedule
Public Property ID As Int32
Public Property Duration As String
'Foreign key of airplane_Id
Public Overridable Property Airplane As Airplane
'Foreign key of origin_Id
Public Overridable Property Origin As Origin
End Class
Airplane.vb
Public Class Airplane
Public Property ID As Int32
Public Property PlaneCode As String
End Class
Origin.vb
Public Class Origin
Public Property ID As Int32
Public Property OriginName As String
End Class
Моя сетка:
<asp:GridView ID="gvSearchFlight" runat="server" ItemType="CIM.Schedule" SelectMethod="gvSearchFlight_GetData" AutoGenerateColumns="false" GridLines="None">
GridView SelectMethod
:
Dim dbContext As New ApplicationDbContext
Public Function gvSearchFlight_GetData() As IQueryable(Of Schedule)
Dim schedules = (From sche In dbContext.Schedule
Join air In dbContext.Airplane
On sche.Airplane.ID Equals air.ID).ToList()
Return schedules
End Function
Но я продолжаю получать эту ошибку:
Невозможно привести объект типа 'System.Collections.Generic.List 1[VB$AnonymousType_11
2 [CIM.Schedule, CIM.Airplane]]' к типу 'System.Linq.IQueryable`1 [CIM.Расписание] '
Редактировать : Я действительно не знаю, как написать выражение "Выбрать новое" ..
Public Class ScheduleInformation
Public Property Schedule As Schedule
Public Property Airplane As Airplane
Public Property Origin As Origin
End Class
Public Function gvSearchFlight_GetData() As IQueryable(Of ScheduleInformation)
Dim schedules = (From sche In dbContext.Schedule
Join air In dbContext.Airplane On sche.Airplane.ID Equals air.ID
Join ori In dbContext.Origin On sche.Origin.ID Equals ori.ID
Select New ScheduleInformation())
Return schedules
End Function