我将'菜单'表中的值变为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
我只是在DBRepository类中使用此代码
Public Function ListAllMenus() As IQueryable(Of PropAllMenus) Implements IDBRepository.ListAllMenus
Dim result = From p In _db.Menus Select New PropAllMenus With {.MenuID = p.MenuID, .Name = p.Name}
Return result
End Function
这很好用。
但是,我不知道我应该采取什么步骤:
我尝试使用类型为array的属性(包含菜单的成分),但这似乎不起作用。
答案 0 :(得分:0)
你只需要在当前的Menu类中添加一个局部类,如下所示:
public partial class Books
public property IEnumerable< Ingredient > Ingredients
get
return me. MenuIngredients.Select( function (mi) mi.Ingredient);
end get
end Property
public sub AddIngredient( i as Ingredient )
//do the logic here
End Sub
public sub AddIngredient( i as Ingredient )
//do the logic here
End Sub
End
这将包括菜单类中的成分