0
我有一個名爲blog的對象和一個名爲article的對象。博客裏面有很多文章。我選擇我的博客是這樣的:從父對象集合中檢索所有子代
Dim blogs = db.Blogs.Where(Function(b) b.CompanyId = companyId)
如何獲取所選博客中的所有文章?
我想顯示所選博客列表中相應的文章:
Dim articles = ' How do I get all the articles inside of the blogs found?
Return View(articles.ToList())
我的博客實體如下:
Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations
Public Class Blog
Public Property BlogId() As Integer
Public Property CompanyId() As Integer
Public Property Name() As String
Public Property Description() As String
Public Property DateCreated As Date
Public Overridable Property Articles() As ICollection(Of Article)
Public Overridable Property Company() As Company
End Class
Public Class BlogDbContext
Inherits DbContext
Public Property Blogs As DbSet(Of Blog)
Public Property Companies As DbSet(Of Company)
End Class