在我的数据库上下文类中,我有:
Imports System.Data.Entity
Public Class MusicStoreEntities
Inherits DbContext
Public Property Albums As DbSet(Of Album)
Public Property Descriptions As DbSet(Of Description)
End Class
然后,我有专辑和描述的这两个模型
Public Class Album
Public Property AlbumId As Integer
End Class
Public Class Description
Public Property DescriptionId As Integer
Public Property AlbumId As Integer
End Class
从控制器的动作中,我可以使用 Linq 获得专辑的单个描述,如下所示:
Dim album_description As Description = db.Descriptions.Single(Function(g) g.AlbumId = id)
但是,如何获取专辑的描述列表?
Dim album_descriptions As List(Of Description) = db.Descriptions.**???**(Function(g) g.AlbumId = id)