0
我必須做錯了什麼或者我不明白這一點。我試圖用來自我的實體框架的數據填充'PropAllMenus'(有一堆屬性)。但是,當通過函數進行轉換時,我在'WeekMenuRepository'中獲得了'InvaldCastExeption'。下面是代碼:ASP.NET MVC:無法轉換ObjectQuery - > Linq.IQueryable
PropAllMenus
Public Class PropAllMenus
Private _MenuID As Integer
Public Property MenuID() As Integer
Get
Return _MenuID
End Get
Set(ByVal value As Integer)
_MenuID = value
End Set
End Property
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _DaypartID As Integer
Public Property DaypartID() As Integer
Get
Return _DaypartID
End Get
Set(ByVal value As Integer)
_DaypartID = value
End Set
End Property
End Class
WeekMenuRepository
Private _db As New EDMWeekmenuEntities()
Public Function ListAllMenus() As IQueryable(Of PropAllMenus) Implements IWeekMenuRepository.ListAllMenus
Dim result = From p In _db.Menus _
Select p
Return result
End Function
的HomeController
Dim DoThings As New WeekMenuRepository()
Function Index() As ActionResult
Return View(DoThings.ListAllMenus().ToList)
End Function
+1爲'順便說一句'段落。 – 2012-06-03 08:31:06