I have an object called blog and an object called article. There are many articles inside of a blog. I select my blogs like this:
Dim blogs = db.Blogs.Where(Function(b) b.CompanyId = companyId)
How can I get all articles within the selected blogs?
I want to display the articles in a list for the selected blogs:
Dim articles = ' How do I get all the articles inside of the blogs found?
Return View(articles.ToList())
My blog entity is as follows:
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
1 Answer