Hi, i must be doing something wrong or maybe i don't get this. I'm trying to fill 'PropAllMenus' (that has a bunch of properties) with data coming from my entity framework. However, when doing the conversion trough a function i get a 'InvaldCastExeption' in my 'WeekMenuRepository'. Here is the code:
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